neuroidnet.ntr
Class Network

java.lang.Object
  |
  +--neuroidnet.ntr.Network
All Implemented Interfaces:
DebuggerInterface, Expressive, Serializable, Simulation
Direct Known Subclasses:
Network

public abstract class Network
extends Object
implements DebuggerInterface, Serializable, Expressive, Simulation

Container for all Areas that hold Neuroids. Classes extending this one should describe the network architecture and topology.

Various utility functions to be used from the BeanShell environment are defined here. Implements Serializable so that instances of this class (representing the run-time object of the network) can be stored and retrieved as snapshots.

Since:
1.0
Version:
$Revision: 1.16 $
Author:
Cengiz Gunay
See Also:
Area, Neuroid, Serialized Form

Field Summary
protected  Vector areas
          All Areas contained in Network.
protected  ConceptArea conceptArea
          Redundant pointer to instance of the ConceptArea (it is also in areas)
 double deltaT
          Increment of time for algorithms.
(package private)  boolean isConcurrent
          Flag to mean multi thread usage.
static NumberFormat numberFormat
          For formatting real values
protected  Peripheral peripheral
          Peripheral control device
(package private)  Simulation simulateAreas
          Lock variable and thread controller for event dispatching to remote (or local) areas.
(package private)  Task stepArea
          Defines what do to every step given Area object.
(package private)  Set watchList
           
 
Constructor Summary
Network(double deltaT, boolean isConcurrent)
          Creates a new Network instance.
 
Method Summary
 void addArea(Area area)
          Adds an area to the network.
 void addWatch(Neuroid neuroid)
          Sets the watch flag of the neuroid and includes in the list of watched entities.
 void addWatchAll(Set neuroidNames)
          addWatchs all neuroids with names given in argument.
 void advanceTime(double msecs)
          Simulate network for given duration starting from current state.
protected abstract  void build()
          Describes the architecture of the network.
 void finale()
          To be called after everthing else is done.
 Area getArea(String name)
          Returns the Area object given the name.
 ConceptArea getConceptArea()
          Get the value of conceptArea.
 Neuroid getNeuroid(Area area, int neuroidId)
          Returns the Neuroid object, given the area and id.
 Neuroid getNeuroid(NeuroidName neuroidName)
           
 Neuroid getNeuroid(String areaName, int neuroidId)
          Returns the Neuroid object, given the area and id.
 Peripheral getPeripheral()
          Get the value of peripheral.
 String getProperties()
          Return detailed info about network components.
 String getStatus()
          Adds time from conceptArea.
 Set getWatchList()
          Get the value of watchList.
 void init()
          Does nothing.
private  void readObject(ObjectInputStream in)
          Method called when a serialized object is loaded.
 void run()
          Build the network (USED TO: and run the simulation.) Calls build().
 void setConceptArea(ConceptArea v)
          Set the value of conceptArea.
(package private)  void setNumberFormatting()
          Number formatting for text numberFormat
 void setPeripheral(Peripheral v)
          Set the value of peripheral.
 void setWatchList(Set v)
          Set the value of watchList.
protected  void simulation()
          Deprecated. See advanceTime
 void step()
          Updates the state of the Network.
 void stop()
          Delegates the termination request to areas.
 String toString()
          Return brief info about the network.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

areas

protected final Vector areas
All Areas contained in Network.

See Also:
Area

peripheral

protected Peripheral peripheral
Peripheral control device


conceptArea

protected ConceptArea conceptArea
Redundant pointer to instance of the ConceptArea (it is also in areas)

See Also:
areas, ConceptArea

deltaT

public double deltaT
Increment of time for algorithms. TODO: Put it elsewhere; too far to reach!


numberFormat

public static NumberFormat numberFormat
For formatting real values


stepArea

Task stepArea
Defines what do to every step given Area object. That is, Task object that will run Area.step() for all areas contained.

See Also:
AreaInt

simulateAreas

volatile Simulation simulateAreas
Lock variable and thread controller for event dispatching to remote (or local) areas.


isConcurrent

boolean isConcurrent
Flag to mean multi thread usage.


watchList

Set watchList
Constructor Detail

Network

public Network(double deltaT,
               boolean isConcurrent)
Creates a new Network instance.

Parameters:
deltaT - a double value, time increments for each simulation step.
isConcurrent - a boolean value, indicating if the network should be simulated in distributed fashion.
See Also:
build(), simulation()
Method Detail

getConceptArea

public ConceptArea getConceptArea()
Get the value of conceptArea.

Returns:
value of conceptArea.

setConceptArea

public void setConceptArea(ConceptArea v)
Set the value of conceptArea.

Parameters:
v - Value to assign to conceptArea.

getPeripheral

public Peripheral getPeripheral()
Get the value of peripheral.

Returns:
value of peripheral.

setPeripheral

public void setPeripheral(Peripheral v)
Set the value of peripheral.

Parameters:
v - Value to assign to peripheral.

addArea

public void addArea(Area area)
Adds an area to the network.

Parameters:
area - an Area value

getWatchList

public Set getWatchList()
Get the value of watchList.

Returns:
value of watchList.

setWatchList

public void setWatchList(Set v)
Set the value of watchList.

Parameters:
v - Value to assign to watchList.

getArea

public Area getArea(String name)
             throws NameNotFoundException
Returns the Area object given the name. Access method for observing network state.

Specified by:
getArea in interface DebuggerInterface
Parameters:
name - a String value
Returns:
an Area value
NameNotFoundException

getNeuroid

public Neuroid getNeuroid(Area area,
                          int neuroidId)
Returns the Neuroid object, given the area and id. Access method for observing network state.

Specified by:
getNeuroid in interface DebuggerInterface
Parameters:
area - Area in which the neuroid resides.
neuroidId - The id of neuroid in given area.
Returns:
a Neuroid value
See Also:
Neuroid.id, Area, getNeuroid(String,int)

getNeuroid

public Neuroid getNeuroid(String areaName,
                          int neuroidId)
                   throws NameNotFoundException
Returns the Neuroid object, given the area and id. Access method for observing network state.

Specified by:
getNeuroid in interface DebuggerInterface
Parameters:
areaName - Name of the Area in which the neuroid resides.
neuroidId - The id of neuroid in given area.
Returns:
a Neuroid value
NameNotFoundException
See Also:
Neuroid.id, Area, getNeuroid(Area,int)

getNeuroid

public Neuroid getNeuroid(NeuroidName neuroidName)
                   throws NameNotFoundException
NameNotFoundException

addWatch

public void addWatch(Neuroid neuroid)
Sets the watch flag of the neuroid and includes in the list of watched entities.

Specified by:
addWatch in interface DebuggerInterface
Parameters:
neuroid - a Neuroid value

addWatchAll

public void addWatchAll(Set neuroidNames)
                 throws NameNotFoundException
addWatchs all neuroids with names given in argument.

Specified by:
addWatchAll in interface DebuggerInterface
Parameters:
neuroidNames - a Set value
NameNotFoundException
See Also:
addWatch(Neuroid)

init

public void init()
Does nothing. TODO: should do something.

Specified by:
init in interface Simulation

step

public void step()
Updates the state of the Network. Updates all Areas contained within. TODO: Should be called from a thread with certain frequency. TODO: parallel version should not have this.

Specified by:
step in interface Simulation
See Also:
Area

stop

public void stop()
Delegates the termination request to areas.

Specified by:
stop in interface Simulation

build

protected abstract void build()
Describes the architecture of the network. Should be defined in subclasses.


simulation

protected void simulation()
Deprecated. See advanceTime

Runs the simulation on the network. Should be defined in subclasses.

See Also:
advanceTime(double)

toString

public String toString()
Return brief info about the network.

Specified by:
toString in interface Expressive
Overrides:
toString in class Object
Returns:
a String value

getStatus

public String getStatus()
Adds time from conceptArea.

Specified by:
getStatus in interface Expressive
Returns:
a String value
See Also:
Expressive.toString()

getProperties

public String getProperties()
Return detailed info about network components.

Specified by:
getProperties in interface Expressive
Returns:
a String value
See Also:
Expressive.getStatus()

advanceTime

public void advanceTime(double msecs)
Simulate network for given duration starting from current state.

Parameters:
msecs - a double value to simulate this network

setNumberFormatting

void setNumberFormatting()
Number formatting for text numberFormat

See Also:
numberFormat, Network(double, boolean), readObject(java.io.ObjectInputStream)

run

public void run()
Build the network (USED TO: and run the simulation.) Calls build(). Initializes network for parallel or single-threaded execution.

TODO: Change this to build?

See Also:
build(), simulation()

finale

public void finale()
To be called after everthing else is done. Terminates all threads, theoretically should terminate.


readObject

private void readObject(ObjectInputStream in)
                 throws IOException,
                        ClassNotFoundException
Method called when a serialized object is loaded. Only customization done is to set the static numberFormat object via a call to setNumberFormatting().

Parameters:
in - a java.io.ObjectInputStream value
Throws:
IOException - if an error occurs
ClassNotFoundException - if an error occurs