public abstract class NeuralConnection extends Object implements Serializable, RevisionHandler
Modifier and Type | Field and Description |
---|---|
static int |
CONNECTED
This flag is set once the unit has a connection.
|
static int |
INPUT
This unit is an input unit.
|
protected String |
m_id
The string that uniquely (provided naming is done properly) identifies
this unit.
|
protected NeuralConnection[] |
m_inputList
The list of inputs to this unit.
|
protected int[] |
m_inputNums
The numbering for the connections at the other end of the input lines.
|
protected int |
m_numInputs
The number of inputs.
|
protected int |
m_numOutputs
The number of outputs.
|
protected NeuralConnection[] |
m_outputList
The list of outputs from this unit.
|
protected int[] |
m_outputNums
The numbering for the connections at the other end of the out lines.
|
protected int |
m_type
The type of unit this is.
|
protected double |
m_unitError
The error value for this unit, NaN if not calculated.
|
protected double |
m_unitValue
The output value for this unit, NaN if not calculated.
|
protected boolean |
m_weightsUpdated
True if the weights have already been updated.
|
protected double |
m_x
The x coord of this unit purely for displaying purposes.
|
protected double |
m_y
The y coord of this unit purely for displaying purposes.
|
static int |
OUTPUT
This unit is an output unit.
|
static int |
PURE_INPUT
This unit is a pure input unit.
|
static int |
PURE_OUTPUT
This unit is a pure output unit.
|
static int |
UNCONNECTED
This unit is not connected to any others.
|
Constructor and Description |
---|
NeuralConnection(String id)
Constructs The unit with the basic connection information prepared for
use.
|
Modifier and Type | Method and Description |
---|---|
protected void |
allocateInputs()
This will allocate more space for input connection information
if the arrays for this have been filled up.
|
protected void |
allocateOutputs()
Allocates more space for output connection information
if the arrays have been filled up.
|
protected void |
changeInputNum(int n,
int v)
Changes the connection value information for one of the connections.
|
protected void |
changeOutputNum(int n,
int v)
Changes the connection value information for one of the connections.
|
static boolean |
connect(NeuralConnection s,
NeuralConnection t)
Connects two units together.
|
protected boolean |
connectInput(NeuralConnection i,
int n)
This will connect the specified unit to be an input to this unit.
|
protected boolean |
connectOutput(NeuralConnection o,
int n)
This will connect the specified unit to be an output to this unit.
|
static boolean |
disconnect(NeuralConnection s,
NeuralConnection t)
Disconnects two units.
|
protected boolean |
disconnectInput(NeuralConnection i,
int n)
This will disconnect the input with the specific connection number
From this node (only on this end however).
|
protected boolean |
disconnectOutput(NeuralConnection o,
int n)
This will disconnect the output with the specific connection number
From this node (only on this end however).
|
void |
drawHighlight(Graphics g,
int w,
int h)
Call this function to draw the node highlighted.
|
void |
drawInputLines(Graphics g,
int w,
int h)
Call this function to draw the nodes input connections.
|
void |
drawNode(Graphics g,
int w,
int h)
Call this function to draw the node.
|
void |
drawOutputLines(Graphics g,
int w,
int h)
Call this function to draw the nodes output connections.
|
abstract double |
errorValue(boolean calculate)
Call this to get the error value of this unit.
|
String |
getId() |
int[] |
getInputNums()
Use this to get easy access to the input numbers.
|
NeuralConnection[] |
getInputs()
Use this to get easy access to the inputs.
|
int |
getNumInputs() |
int |
getNumOutputs() |
int[] |
getOutputNums()
Use this to get easy access to the output numbers.
|
NeuralConnection[] |
getOutputs()
Use this to get easy access to the outputs.
|
int |
getType() |
double |
getX() |
double |
getY() |
boolean |
onUnit(Graphics g,
int x,
int y,
int w,
int h)
Call this function to determine if the point at x,y is on the unit.
|
abstract double |
outputValue(boolean calculate)
Call this to get the output value of this unit.
|
void |
removeAllInputs()
This function will remove all the inputs to this unit.
|
void |
removeAllOutputs()
This function will remove all outputs to this unit.
|
abstract void |
reset()
Call this to reset the unit for another run.
|
abstract void |
restoreWeights()
Call this to have the connection restore from the saved
weights.
|
abstract void |
saveWeights()
Call this to have the connection save the current
weights.
|
void |
setType(int t) |
void |
setX(double x) |
void |
setY(double y) |
void |
updateWeights(double l,
double m)
Call this function to update the weight values at this unit.
|
double |
weightValue(int n)
Call this to get the weight value on a particular connection.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getRevision
public static final int UNCONNECTED
public static final int PURE_INPUT
public static final int PURE_OUTPUT
public static final int INPUT
public static final int OUTPUT
public static final int CONNECTED
protected NeuralConnection[] m_inputList
protected NeuralConnection[] m_outputList
protected int[] m_inputNums
protected int[] m_outputNums
protected int m_numInputs
protected int m_numOutputs
protected double m_unitValue
protected double m_unitError
protected boolean m_weightsUpdated
protected String m_id
protected int m_type
protected double m_x
protected double m_y
public NeuralConnection(String id)
id
- the unique id of the unitpublic String getId()
public int getType()
public void setType(int t)
t
- The new type of this unit.public abstract void reset()
public abstract double outputValue(boolean calculate)
calculate
- True if the value should be calculated if it hasn't been
already.public abstract double errorValue(boolean calculate)
calculate
- True if the value should be calculated if it hasn't been
already.public abstract void saveWeights()
public abstract void restoreWeights()
public double weightValue(int n)
n
- The connection number to get the weight for, -1 if The threshold
weight should be returned.public void updateWeights(double l, double m)
l
- The learning Rate to use.m
- The momentum to use.public NeuralConnection[] getInputs()
public NeuralConnection[] getOutputs()
public int[] getInputNums()
public int[] getOutputNums()
public double getX()
public double getY()
public void setX(double x)
x
- The new value for it's x pos.public void setY(double y)
y
- The new value for it's y pos.public boolean onUnit(Graphics g, int x, int y, int w, int h)
g
- The graphics context for font size info.x
- The x coord.y
- The y coord.w
- The width of the display.h
- The height of the display.public void drawNode(Graphics g, int w, int h)
g
- The graphics context.w
- The width of the drawing area.h
- The height of the drawing area.public void drawHighlight(Graphics g, int w, int h)
g
- The graphics context.w
- The width of the drawing area.h
- The height of the drawing area.public void drawInputLines(Graphics g, int w, int h)
g
- The graphics context.w
- The width of the drawing area.h
- The height of the drawing area.public void drawOutputLines(Graphics g, int w, int h)
g
- The graphics context.w
- The width of the drawing area.h
- The height of the drawing area.protected boolean connectInput(NeuralConnection i, int n)
i
- The unit.n
- It's connection number for this connection.protected void allocateInputs()
protected boolean connectOutput(NeuralConnection o, int n)
o
- The unit.n
- It's connection number for this connection.protected void allocateOutputs()
protected boolean disconnectInput(NeuralConnection i, int n)
i
- The unit to disconnect.n
- The connection number at the other end, -1 if all the connections
to this unit should be severed.public void removeAllInputs()
protected void changeInputNum(int n, int v)
n
- The connection number to change.v
- The value to change it to.protected boolean disconnectOutput(NeuralConnection o, int n)
o
- The unit to disconnect.n
- The connection number at the other end, -1 if all the connections
to this unit should be severed.public void removeAllOutputs()
protected void changeOutputNum(int n, int v)
n
- The connection number to change.v
- The value to change it to.public int getNumInputs()
public int getNumOutputs()
public static boolean connect(NeuralConnection s, NeuralConnection t)
s
- The source unit.t
- The target unit.public static boolean disconnect(NeuralConnection s, NeuralConnection t)
s
- The source unit.t
- The target unit.Copyright © 2015 University of Waikato, Hamilton, NZ. All rights reserved.