org.joone.io
Class StreamInputSynapse

java.lang.Object
  extended by org.joone.engine.Synapse
      extended by org.joone.io.StreamInputSynapse
All Implemented Interfaces:
java.io.Serializable, InputPatternListener, Learnable, LearnableSynapse, NeuralElement, OutputPatternListener, Inspectable, InputSynapse, PlugInListener
Direct Known Subclasses:
FileInputSynapse, ImageInputSynapse, InputConnector, InputSwitchSynapse, JDBCInputSynapse, MemoryInputSynapse, URLInputSynapse, XLSInputSynapse, YahooFinanceInputSynapse

public abstract class StreamInputSynapse
extends Synapse
implements InputSynapse, Inspectable

See Also:
Serialized Form

Field Summary
protected  int[] cols
           
protected  int currentRow
           
protected  boolean EOF
           
protected  java.util.Vector InputVector
           
protected  java.util.List plugInListeners
          List of plug-in listeners (often input connectors).
protected  PatternTokenizer tokens
           
 
Fields inherited from class org.joone.engine.Synapse
array, b_pattern, bitems, bouts, count, enabled, fwdLock, inps, items, learnable, m_batch, m_pattern, myLearner, outs, revLock
 
Constructor Summary
StreamInputSynapse()
           
 
Method Summary
 boolean addPlugIn(ConverterPlugIn aNewPlugIn)
          Adds a plug in to the stream input synapse for data preprocessing.
 void addPlugInListener(PlugInListener aListener)
          Adds a plug-in lsitener to this input stream.
protected  void backward(double[] pattern)
          Funzione di TRAIN dell'elemento.
 java.util.TreeSet check()
          Check that parameters are set correctly.
 void dataChanged(PlugInEvent data)
          This method is called by plug-ins whenever data is changed.
protected  void fireDataChanged()
          Fires an event to the plug-in listeners notifying that the underlying data has changed.
protected  void forward(double[] pattern)
          Recall function
 Pattern fwdGet()
          Returns the pattern coming from the previous layer during the recall phase
 Pattern fwdGet(InputConnector conn)
          This method is called by the InputConnector in order to get the next input pattern available for that connector
 java.lang.String getAdvancedColumnSelector()
           
 java.util.List getAllPlugInListeners()
          Gets all the plug-in listeners.
 int getCurrentRow()
          Getter for property currentRow.
 char getDecimalPoint()
          Returns the decimal point accepted (19/04/00 0.23.56)
 int getFirstCol()
          Deprecated.  
 int getFirstRow()
           
 java.util.Vector getInputPatterns()
          Getter for property inputPatterns.
protected  java.util.Vector getInputVector()
           
 int getLastCol()
          Deprecated.  
 int getLastRow()
           
 int getMaxBufSize()
          Getter for property maxBufSize.
 ConverterPlugIn getPlugIn()
          Gets the attached ConverterPlugin, if any
protected  Pattern getStream()
           
protected  PatternTokenizer getTokens()
          Getter for property tokens.
 void gotoFirstLine()
           
 void gotoLine(int numLine)
          Point to the indicated line into the input stream
protected  void handleExceptionWithError(java.lang.Exception ex, java.lang.String errMsg, ILogger log)
           
protected  void handleExceptionWithWarn(java.lang.Exception ex, java.lang.String errMsg, ILogger logger)
           
protected abstract  void initInputStream()
           
 java.lang.String InspectableTitle()
          Method to get the title to show in the InspectionFrame tab.
 java.util.Collection Inspections()
          Method to get a collection of inspectable objects.
 boolean isBuffered()
          Checks if the input synapse is buffered or not
 boolean isEOF()
          Returns if reached the EOF (10/04/00 23.16.20)
 boolean isStepCounter()
          Returns if this input layer is an active counter of the steps.
 int numColumns()
           
 void readAll()
          Reads all input values and fills the buffer
protected  void readObjectBase(java.io.ObjectInputStream in)
           
 void removeAllPlugIns()
          Removes (and disconnects) all (cascading) plug-ins.
 void removePlugInListener(PlugInListener aListener)
          Removes a plug-in listener from this input stream.
 void reset()
          reset the state of the input synapse
 void resetInput()
          Reset the input stream to read its content again
protected  void restart()
           
 void revPut(Pattern array)
          Method to put an error pattern backward to the previous layer
 void setAdvancedColumnSelector(java.lang.String newAdvColSel)
           
protected  void setArrays(int rows, int cols)
          setArrays method.
 void setBuffered(boolean aNewBuffered)
          Sets the buffer-mode for this input synapse.
protected  void setColList()
          Sets the list of columns that must be returned as the pattern Creation date: (18/10/2000 0.45.52)
 void setDecimalPoint(char dp)
           
protected  void setDimensions(int rows, int cols)
          Dimensiona l'elemento
protected  void setEOF(boolean newEOF)
           
 void setFirstCol(int firstCol)
          Deprecated.  
 void setFirstRow(int newFirstRow)
          Inserire qui la descrizione del metodo.
 void setInputPatterns(java.util.Vector inputPatterns)
          Setter for property inputPatterns.
 void setLastCol(int lastCol)
          Deprecated.  
 void setLastRow(int newLastRow)
          Inserire qui la descrizione del metodo.
 void setMaxBufSize(int maxBufSize)
          Setter for property maxBufSize.
 boolean setPlugin(ConverterPlugIn newPlugIn)
          Deprecated. addPlugIn(ConverterPlugIn). If you want to replace the plug in by setting a new plug in please use #removeAllPlugIns(ConverterPlugIn) and addPlugIn(ConverterPlugIn).
 void setPlugIn(ConverterPlugIn newPlugIn)
          Added for XML serialization **** DO NOT USE **** Use addPlugin instead
 void setStepCounter(boolean newStepCounter)
          Inserire qui la descrizione del metodo.
protected  void setTokens(PatternTokenizer tkn)
           
protected  void writeObjectBase(java.io.ObjectOutputStream out)
           
protected  Pattern zeroPattern()
           
 
Methods inherited from class org.joone.engine.Synapse
addNoise, canCountSteps, fwdPattern_consume, fwdPattern_produce, fwdPut, getCount, getFwdLock, getIgnoreBefore, getInputDimension, getLearner, getLearningRate, getMomentum, getMonitor, getName, getOutputDimension, getRevLock, getSynapseNameSafely, getWeights, init, initLearner, isEnabled, isInputFull, isLoopBack, isOutputFull, randomize, readResolve, revGet, revPattern_consume, revPattern_produce, setEnabled, setIgnoreBefore, setInputDimension, setInputFull, setLearningRate, setLoopBack, setMomentum, setMonitor, setName, setOutputDimension, setOutputFull, setWeights, warnLogger, warnLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cols

protected transient int[] cols

InputVector

protected transient java.util.Vector InputVector

currentRow

protected transient int currentRow

tokens

protected transient PatternTokenizer tokens

EOF

protected transient boolean EOF

plugInListeners

protected java.util.List plugInListeners
List of plug-in listeners (often input connectors).

Constructor Detail

StreamInputSynapse

public StreamInputSynapse()
Method Detail

backward

protected void backward(double[] pattern)
Description copied from class: Synapse
Funzione di TRAIN dell'elemento.

Specified by:
backward in class Synapse
Parameters:
pattern - double[] - pattern di input sul quale applicare la funzione di trasferimento

forward

protected void forward(double[] pattern)
Description copied from class: Synapse
Recall function

Specified by:
forward in class Synapse
Parameters:
pattern - double[] - input pattern. THIS PATTERN CANNOT BE CHANGED

fwdGet

public Pattern fwdGet()
Description copied from interface: InputPatternListener
Returns the pattern coming from the previous layer during the recall phase

Specified by:
fwdGet in interface InputPatternListener
Overrides:
fwdGet in class Synapse
Returns:
neural.engine.Pattern

getDecimalPoint

public char getDecimalPoint()
Returns the decimal point accepted (19/04/00 0.23.56)

Specified by:
getDecimalPoint in interface InputSynapse
Returns:
char

getFirstRow

public int getFirstRow()
Specified by:
getFirstRow in interface InputSynapse
Returns:
int

getInputVector

protected java.util.Vector getInputVector()
Returns:
java.util.Vector

getLastRow

public int getLastRow()
Specified by:
getLastRow in interface InputSynapse
Returns:
int

getStream

protected Pattern getStream()
                     throws java.io.IOException
Throws:
java.io.IOException

gotoFirstLine

public void gotoFirstLine()
                   throws java.io.IOException
Specified by:
gotoFirstLine in interface InputSynapse
Throws:
java.io.IOException

gotoLine

public void gotoLine(int numLine)
              throws java.io.IOException
Point to the indicated line into the input stream

Specified by:
gotoLine in interface InputSynapse
Throws:
java.io.IOException

isBuffered

public boolean isBuffered()
Checks if the input synapse is buffered or not

Specified by:
isBuffered in interface InputSynapse
Returns:
true in case the input stream is buffered, false otherwise.

isEOF

public boolean isEOF()
Returns if reached the EOF (10/04/00 23.16.20)

Specified by:
isEOF in interface InputSynapse
Returns:
boolean

isStepCounter

public boolean isStepCounter()
Returns if this input layer is an active counter of the steps. Warning: in a neural net there can be only one StepCounter element! (10/04/00 23.23.26)

Specified by:
isStepCounter in interface InputSynapse
Returns:
boolean

numColumns

public int numColumns()

readAll

public void readAll()
Reads all input values and fills the buffer

Specified by:
readAll in interface InputSynapse

revPut

public void revPut(Pattern array)
Description copied from interface: InputPatternListener
Method to put an error pattern backward to the previous layer

Specified by:
revPut in interface InputPatternListener
Overrides:
revPut in class Synapse
Parameters:
array - neural.engine.Pattern

setArrays

protected void setArrays(int rows,
                         int cols)
setArrays method.

Specified by:
setArrays in class Synapse

setBuffered

public void setBuffered(boolean aNewBuffered)
Sets the buffer-mode for this input synapse.

Specified by:
setBuffered in interface InputSynapse
Parameters:
aNewBuffered - true if the input should be buffered. false if the input should not be buffered, the input will be retrieved from the input source every cycle again.

Whenever any converter plug in is added, the buffer-mode will be set to true, regardless of the parameter's argument.


setColList

protected void setColList()
Sets the list of columns that must be returned as the pattern Creation date: (18/10/2000 0.45.52)

Parameters:
cols - java.util.Vector

setDecimalPoint

public void setDecimalPoint(char dp)
Specified by:
setDecimalPoint in interface InputSynapse

setDimensions

protected void setDimensions(int rows,
                             int cols)
Description copied from class: Synapse
Dimensiona l'elemento

Specified by:
setDimensions in class Synapse

setEOF

protected void setEOF(boolean newEOF)

setFirstRow

public void setFirstRow(int newFirstRow)
Inserire qui la descrizione del metodo. Data di creazione: (11/04/00 1.22.28)

Specified by:
setFirstRow in interface InputSynapse
Parameters:
newFirstRow - int

resetInput

public void resetInput()
Reset the input stream to read its content again

Specified by:
resetInput in interface InputSynapse

restart

protected void restart()

setLastRow

public void setLastRow(int newLastRow)
Inserire qui la descrizione del metodo. Data di creazione: (11/04/00 1.22.34)

Specified by:
setLastRow in interface InputSynapse
Parameters:
newLastRow - int

addPlugIn

public boolean addPlugIn(ConverterPlugIn aNewPlugIn)
Adds a plug in to the stream input synapse for data preprocessing. If one or more plug ins are already added to the this synapse, the plug in will be added at the end of the list of plug ins. If null is passed whole plugin stack is removed

Parameters:
aNewPlugIn - The new converter plug in to add (at the end of the list).
Returns:
true when the plug in is added, false when the plug in is not added, e.g. in case the plug in is already added / connected to another synapse.

removeAllPlugIns

public void removeAllPlugIns()
Removes (and disconnects) all (cascading) plug-ins.


setPlugin

public boolean setPlugin(ConverterPlugIn newPlugIn)
Deprecated. addPlugIn(ConverterPlugIn). If you want to replace the plug in by setting a new plug in please use #removeAllPlugIns(ConverterPlugIn) and addPlugIn(ConverterPlugIn).

Sets the plugin for the data preprocessing.

Parameters:
newPlugIn - the plug in to set

getPlugIn

public ConverterPlugIn getPlugIn()
Gets the attached ConverterPlugin, if any

Returns:
neural.engine.ConverterPlugIn

setPlugIn

public void setPlugIn(ConverterPlugIn newPlugIn)
Added for XML serialization **** DO NOT USE **** Use addPlugin instead


setStepCounter

public void setStepCounter(boolean newStepCounter)
Inserire qui la descrizione del metodo. Data di creazione: (10/04/00 23.23.26)

Specified by:
setStepCounter in interface InputSynapse
Parameters:
newStepCounter - boolean

writeObjectBase

protected void writeObjectBase(java.io.ObjectOutputStream out)
                        throws java.io.IOException
Throws:
java.io.IOException

readObjectBase

protected void readObjectBase(java.io.ObjectInputStream in)
                       throws java.io.IOException,
                              java.lang.ClassNotFoundException
Throws:
java.io.IOException
java.lang.ClassNotFoundException

getLastCol

public int getLastCol()
Deprecated. 

Getter for property lastCol.

Specified by:
getLastCol in interface InputSynapse
Returns:
Value of property lastCol.

setLastCol

public void setLastCol(int lastCol)
                throws java.lang.IllegalArgumentException
Deprecated. 

Setter for property lastCol.

Specified by:
setLastCol in interface InputSynapse
Parameters:
lastCol - New value of property lastCol.
Throws:
java.lang.IllegalArgumentException

getFirstCol

public int getFirstCol()
Deprecated. 

Getter for property firstCol.

Specified by:
getFirstCol in interface InputSynapse
Returns:
Value of property firstCol.

setFirstCol

public void setFirstCol(int firstCol)
                 throws java.lang.IllegalArgumentException
Deprecated. 

Setter for property firstCol.

Specified by:
setFirstCol in interface InputSynapse
Parameters:
firstCol - New value of property firstCol.
Throws:
java.lang.IllegalArgumentException

getAdvancedColumnSelector

public java.lang.String getAdvancedColumnSelector()

setAdvancedColumnSelector

public void setAdvancedColumnSelector(java.lang.String newAdvColSel)

dataChanged

public void dataChanged(PlugInEvent data)
Description copied from interface: PlugInListener
This method is called by plug-ins whenever data is changed.

Specified by:
dataChanged in interface PlugInListener
Parameters:
data - the event that is send, i.e. the event indicating that the data is changed.

getTokens

protected PatternTokenizer getTokens()
                              throws JooneRuntimeException
Getter for property tokens.

Returns:
Value of property tokens.
Throws:
JooneRuntimeException

setTokens

protected void setTokens(PatternTokenizer tkn)

zeroPattern

protected Pattern zeroPattern()

initInputStream

protected abstract void initInputStream()
                                 throws JooneRuntimeException
Throws:
JooneRuntimeException

check

public java.util.TreeSet check()
Check that parameters are set correctly.

Specified by:
check in interface NeuralElement
Overrides:
check in class Synapse
Returns:
validation errors.
See Also:
Synapse

Inspections

public java.util.Collection Inspections()
Description copied from interface: Inspectable
Method to get a collection of inspectable objects.

Specified by:
Inspections in interface Inspectable
Overrides:
Inspections in class Synapse
Returns:
list of Inspectable objects
See Also:
org.joone.Inspection

InspectableTitle

public java.lang.String InspectableTitle()
Description copied from interface: Inspectable
Method to get the title to show in the InspectionFrame tab.

Specified by:
InspectableTitle in interface Inspectable
Overrides:
InspectableTitle in class Synapse
Returns:
title of the class.
See Also:
org.joone.InspectionFrame

reset

public void reset()
reset the state of the input synapse

Specified by:
reset in interface InputPatternListener
Overrides:
reset in class Synapse

getMaxBufSize

public int getMaxBufSize()
Getter for property maxBufSize.

Returns:
Value of property maxBufSize.

setMaxBufSize

public void setMaxBufSize(int maxBufSize)
Setter for property maxBufSize.

Parameters:
maxBufSize - New value of property maxBufSize.

getInputPatterns

public java.util.Vector getInputPatterns()
Getter for property inputPatterns. Added for XML serialization

Returns:
Value of property inputPatterns.

setInputPatterns

public void setInputPatterns(java.util.Vector inputPatterns)
Setter for property inputPatterns. Added for XML serialization

Parameters:
inputPatterns - New value of property inputPatterns.

fwdGet

public Pattern fwdGet(InputConnector conn)
This method is called by the InputConnector in order to get the next input pattern available for that connector


getCurrentRow

public int getCurrentRow()
Getter for property currentRow.

Returns:
Value of property currentRow.

addPlugInListener

public void addPlugInListener(PlugInListener aListener)
Adds a plug-in lsitener to this input stream.

Parameters:
aListener - the listener to add

removePlugInListener

public void removePlugInListener(PlugInListener aListener)
Removes a plug-in listener from this input stream.

Parameters:
aListener - the listener to remove

getAllPlugInListeners

public java.util.List getAllPlugInListeners()
Gets all the plug-in listeners.

Returns:
the plug-in listeners.

fireDataChanged

protected void fireDataChanged()
Fires an event to the plug-in listeners notifying that the underlying data has changed.


handleExceptionWithWarn

protected void handleExceptionWithWarn(java.lang.Exception ex,
                                       java.lang.String errMsg,
                                       ILogger logger)
Parameters:
ex -
errMsg -
log -

handleExceptionWithError

protected void handleExceptionWithError(java.lang.Exception ex,
                                        java.lang.String errMsg,
                                        ILogger log)
Parameters:
ex -
errMsg -
log -


Submit Feedback to pmarrone@users.sourceforge.net