org.jscience.architecture.traffic.algorithms.tlc
Class ACGJ4

java.lang.Object
  extended by org.jscience.architecture.traffic.algorithms.tlc.TLController
      extended by org.jscience.architecture.traffic.algorithms.tlc.ACGJ4
All Implemented Interfaces:
InstantiationAssistant, TwoStageLoader, XMLSerializable

public class ACGJ4
extends TLController
implements InstantiationAssistant, XMLSerializable

DOCUMENT ME!


Nested Class Summary
protected  class ACGJ4.Individual
          DOCUMENT ME!
protected  class ACGJ4.Population
          DOCUMENT ME!
 
Nested classes/interfaces inherited from class org.jscience.architecture.traffic.algorithms.tlc.TLController
TLController.TLCDialog, TLController.TLCSettings
 
Field Summary
protected  InstantiationAssistant assistant
          DOCUMENT ME!
protected static float CROSSOVER_CHANCE
          A constant for the chance that genes cross over
protected static float ELITISM_FACTOR
          DOCUMENT ME!
protected  ACGJ4.Individual ind
          the current Individual that is running
protected static float MUTATION_CHANCE
          A constant for the chance that mutation occurs
protected  int num_move
          counter for the number of roadusers that did move
protected  int num_nodes
          counter for the number of roadusers that did move
protected  int num_step
          counter for the number of steps the simulation has ran yet
protected static int NUM_STEPS
          A constant for the number of steps an individual may run
protected  int num_wait
          counter for how many roadusers had to wait a turn
protected static int NUMBER_GENERATIONS
          A constant for the number of generations
protected static int NUMBER_INDIVIDUALS
          A constant for the number of individuals
protected  ACGJ4.Population pop
          The Population of Individuals
protected  java.util.Random random
          The pseudo-random number generator for generating the chances that certain events will occur
protected static java.lang.String shortXMLName
          DOCUMENT ME!
protected  TLController tlc
          the current TLController being used to determine gains
 
Fields inherited from class org.jscience.architecture.traffic.algorithms.tlc.TLController
infra, num_tls, tld, trackNode
 
Constructor Summary
ACGJ4(Infrastructure i)
          Creates a new ACGJ3 Algorithm.
 
Method Summary
 boolean canCreateInstance(java.lang.Class request)
          DOCUMENT ME!
 java.lang.Object createInstance(java.lang.Class request)
          DOCUMENT ME!
 TLDecision[][] decideTLs()
          Calculates how every traffic light should be switched
 java.lang.String getXMLName()
          DOCUMENT ME!
 void load(XMLElement myElement, XMLLoader loader)
          DOCUMENT ME!
 void reset()
          Resets the algorithm
 void saveChilds(XMLSaver saver)
          DOCUMENT ME!
 XMLElement saveSelf()
          DOCUMENT ME!
 void setInfrastructure(Infrastructure _i)
          Changes the Infrastructure this algorithm is working on
 void showSettings(Controller c)
          DOCUMENT ME!
 void updateRoaduserMove(Roaduser _ru, Drivelane _prevlane, Sign _prevsign, int _prevpos, Drivelane _dlanenow, Sign _signnow, int _posnow, PosMov[] posMovs, Drivelane _desired)
          Provides the TLC-algorithm with information about a roaduser that has had it's go in the moveAllRoaduser-cycle.
 
Methods inherited from class org.jscience.architecture.traffic.algorithms.tlc.TLController
applyGainValues, createDecisionArray, doSettingsDialog, getGainValuesFromDecisionArray, getInfrastructure, getNumTLs, loadSecondStage, setParentName, trackNode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jscience.architecture.traffic.xml.XMLSerializable
setParentName
 

Field Detail

NUM_STEPS

protected static int NUM_STEPS
A constant for the number of steps an individual may run


CROSSOVER_CHANCE

protected static float CROSSOVER_CHANCE
A constant for the chance that genes cross over


MUTATION_CHANCE

protected static float MUTATION_CHANCE
A constant for the chance that mutation occurs


ELITISM_FACTOR

protected static float ELITISM_FACTOR
DOCUMENT ME!


NUMBER_INDIVIDUALS

protected static int NUMBER_INDIVIDUALS
A constant for the number of individuals


NUMBER_GENERATIONS

protected static int NUMBER_GENERATIONS
A constant for the number of generations


shortXMLName

protected static final java.lang.String shortXMLName
DOCUMENT ME!

See Also:
Constant Field Values

num_step

protected int num_step
counter for the number of steps the simulation has ran yet


num_wait

protected int num_wait
counter for how many roadusers had to wait a turn


num_move

protected int num_move
counter for the number of roadusers that did move


num_nodes

protected int num_nodes
counter for the number of roadusers that did move


tlc

protected TLController tlc
the current TLController being used to determine gains


ind

protected ACGJ4.Individual ind
the current Individual that is running


pop

protected ACGJ4.Population pop
The Population of Individuals


random

protected java.util.Random random
The pseudo-random number generator for generating the chances that certain events will occur


assistant

protected InstantiationAssistant assistant
DOCUMENT ME!

Constructor Detail

ACGJ4

public ACGJ4(Infrastructure i)
Creates a new ACGJ3 Algorithm. This TLC-algorithm is using genetic techniques to find an optimum in calculating the gains for each trafficlight. Till date it hasnt functioned that well. Rather poorly, to just say it.

Parameters:
i - The infrastructure this algorithm will have to operate on
Method Detail

setInfrastructure

public void setInfrastructure(Infrastructure _i)
Changes the Infrastructure this algorithm is working on

Overrides:
setInfrastructure in class TLController
Parameters:
_i - The new infrastructure for which the algorithm has to be set up

decideTLs

public TLDecision[][] decideTLs()
Calculates how every traffic light should be switched

Specified by:
decideTLs in class TLController
Returns:
Returns a double array of TLDecision's. These are tuples of a TrafficLight and the gain-value of when it's set to green.
See Also:
gld.algo.tlc.TLDecision

reset

public void reset()
Resets the algorithm

Overrides:
reset in class TLController

updateRoaduserMove

public void updateRoaduserMove(Roaduser _ru,
                               Drivelane _prevlane,
                               Sign _prevsign,
                               int _prevpos,
                               Drivelane _dlanenow,
                               Sign _signnow,
                               int _posnow,
                               PosMov[] posMovs,
                               Drivelane _desired)
Provides the TLC-algorithm with information about a roaduser that has had it's go in the moveAllRoaduser-cycle. From this information it can be distilled whether a roaduser has moved or had to wait.

Specified by:
updateRoaduserMove in class TLController
Parameters:
_ru -
_prevlane -
_prevsign -
_prevpos -
_dlanenow -
_signnow -
_posnow -
posMovs -
_desired -

showSettings

public void showSettings(Controller c)
DOCUMENT ME!

Overrides:
showSettings in class TLController
Parameters:
c - DOCUMENT ME!

load

public void load(XMLElement myElement,
                 XMLLoader loader)
          throws XMLTreeException,
                 java.io.IOException,
                 XMLInvalidInputException
DOCUMENT ME!

Specified by:
load in interface XMLSerializable
Overrides:
load in class TLController
Parameters:
myElement - DOCUMENT ME!
loader - DOCUMENT ME!
Throws:
XMLTreeException - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
XMLInvalidInputException - DOCUMENT ME!

saveSelf

public XMLElement saveSelf()
                    throws XMLCannotSaveException
DOCUMENT ME!

Specified by:
saveSelf in interface XMLSerializable
Overrides:
saveSelf in class TLController
Returns:
DOCUMENT ME!
Throws:
XMLCannotSaveException - DOCUMENT ME!

saveChilds

public void saveChilds(XMLSaver saver)
                throws XMLTreeException,
                       java.io.IOException,
                       XMLCannotSaveException
DOCUMENT ME!

Specified by:
saveChilds in interface XMLSerializable
Overrides:
saveChilds in class TLController
Parameters:
saver - DOCUMENT ME!
Throws:
XMLTreeException - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
XMLCannotSaveException - DOCUMENT ME!

getXMLName

public java.lang.String getXMLName()
DOCUMENT ME!

Specified by:
getXMLName in interface XMLSerializable
Returns:
DOCUMENT ME!

createInstance

public java.lang.Object createInstance(java.lang.Class request)
                                throws java.lang.ClassNotFoundException,
                                       java.lang.InstantiationException,
                                       java.lang.IllegalAccessException
DOCUMENT ME!

Specified by:
createInstance in interface InstantiationAssistant
Parameters:
request - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.lang.ClassNotFoundException - DOCUMENT ME!
java.lang.InstantiationException - DOCUMENT ME!
java.lang.IllegalAccessException - DOCUMENT ME!

canCreateInstance

public boolean canCreateInstance(java.lang.Class request)
DOCUMENT ME!

Specified by:
canCreateInstance in interface InstantiationAssistant
Parameters:
request - DOCUMENT ME!
Returns:
DOCUMENT ME!