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

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

public class TC1TLCDestless
extends TLController
implements Colearning, InstantiationAssistant

This controller will decide it's Q values for the traffic lights according to the traffic situation on the lane connected to the TrafficLight. It will learn how to alter it's outcome by reinforcement learning. Now Optimized 2.0 Now Long-Fixed, so run run run, Forrest! Now doesnt use Destinations


Nested Class Summary
 class TC1TLCDestless.CountEntry
           
 class TC1TLCDestless.PEntry
          DOCUMENT ME!
 
Nested classes/interfaces inherited from class org.jscience.architecture.traffic.algorithms.tlc.TLController
TLController.TLCDialog, TLController.TLCSettings
 
Field Summary
protected  Node[] allnodes
          DOCUMENT ME!
protected  java.util.Vector[][][] count
          DOCUMENT ME!
protected static float gamma
          DOCUMENT ME!
protected static boolean green
          DOCUMENT ME!
protected static int green_index
          DOCUMENT ME!
protected  Infrastructure infrastructure
          DOCUMENT ME!
protected  int num_nodes
          DOCUMENT ME!
protected  java.util.Vector[][][] pTable
          DOCUMENT ME!
protected  float[][][][] qTable
          DOCUMENT ME!
protected static float random_chance
          DOCUMENT ME!
protected static boolean red
          DOCUMENT ME!
protected static int red_index
          DOCUMENT ME!
protected static java.lang.String shortXMLName
          DOCUMENT ME!
protected  TrafficLight[][] tls
          DOCUMENT ME!
protected  float[][][] vTable
          DOCUMENT ME!
 
Fields inherited from class org.jscience.architecture.traffic.algorithms.tlc.TLController
infra, num_tls, tld, trackNode
 
Constructor Summary
TC1TLCDestless(Infrastructure infra)
          The constructor for TL controllers
 
Method Summary
protected  float[] calcPGR(int tlId, int pos, int desId)
           
 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 Per node, per sign the waiting roadusers are passed and per each roaduser the gain is calculated.
 float getColearnValue(Sign now, Sign sign, Node des, int pos)
          DOCUMENT ME!
 float getVValue(Sign sign, Node des, int pos)
          DOCUMENT ME!
 java.lang.String getXMLName()
          DOCUMENT ME!
 void load(XMLElement myElement, XMLLoader loader)
          DOCUMENT ME!
protected  void recalcP(int tlId, int pos, int desId, boolean light, int tlNewId, int posNew)
          DOCUMENT ME!
protected  void recalcQ(int tlId, int pos, int desId, boolean light, int tlNewId, int posNew, PosMov[] posMovs)
          DOCUMENT ME!
protected  void recalcV(int tlId, int pos, int desId)
          DOCUMENT ME!
protected  int rewardFunction(int tlId, int pos, int tlNewId, int posNew)
          DOCUMENT ME!
 void saveChilds(XMLSaver saver)
          DOCUMENT ME!
 XMLElement saveSelf()
          DOCUMENT ME!
 void setInfrastructure(Infrastructure infra)
          DOCUMENT ME!
 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)
          DOCUMENT ME!
 
Methods inherited from class org.jscience.architecture.traffic.algorithms.tlc.TLController
applyGainValues, createDecisionArray, doSettingsDialog, getGainValuesFromDecisionArray, getInfrastructure, getNumTLs, loadSecondStage, reset, setParentName, trackNode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

gamma

protected static float gamma
DOCUMENT ME!


red

protected static final boolean red
DOCUMENT ME!

See Also:
Constant Field Values

green

protected static final boolean green
DOCUMENT ME!

See Also:
Constant Field Values

green_index

protected static final int green_index
DOCUMENT ME!

See Also:
Constant Field Values

red_index

protected static final int red_index
DOCUMENT ME!

See Also:
Constant Field Values

shortXMLName

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

See Also:
Constant Field Values

random_chance

protected static float random_chance
DOCUMENT ME!


infrastructure

protected Infrastructure infrastructure
DOCUMENT ME!


tls

protected TrafficLight[][] tls
DOCUMENT ME!


allnodes

protected Node[] allnodes
DOCUMENT ME!


num_nodes

protected int num_nodes
DOCUMENT ME!


count

protected java.util.Vector[][][] count
DOCUMENT ME!


pTable

protected java.util.Vector[][][] pTable
DOCUMENT ME!


qTable

protected float[][][][] qTable
DOCUMENT ME!


vTable

protected float[][][] vTable
DOCUMENT ME!

Constructor Detail

TC1TLCDestless

public TC1TLCDestless(Infrastructure infra)
               throws InfraException
The constructor for TL controllers

Parameters:
infra - model being used.
Throws:
InfraException - DOCUMENT ME!
Method Detail

setInfrastructure

public void setInfrastructure(Infrastructure infra)
DOCUMENT ME!

Overrides:
setInfrastructure in class TLController
Parameters:
infra - DOCUMENT ME!

decideTLs

public TLDecision[][] decideTLs()
Calculates how every traffic light should be switched Per node, per sign the waiting roadusers are passed and per each roaduser the gain is calculated.

Specified by:
decideTLs in class TLController
Returns:
DOCUMENT ME!
See Also:
gld.algo.tlc.TLDecision

updateRoaduserMove

public void updateRoaduserMove(Roaduser ru,
                               Drivelane prevlane,
                               Sign prevsign,
                               int prevpos,
                               Drivelane dlanenow,
                               Sign signnow,
                               int posnow,
                               PosMov[] posMovs,
                               Drivelane desired)
DOCUMENT ME!

Specified by:
updateRoaduserMove in class TLController
Parameters:
ru - DOCUMENT ME!
prevlane - DOCUMENT ME!
prevsign - DOCUMENT ME!
prevpos - DOCUMENT ME!
dlanenow - DOCUMENT ME!
signnow - DOCUMENT ME!
posnow - DOCUMENT ME!
posMovs - DOCUMENT ME!
desired - DOCUMENT ME!

recalcP

protected void recalcP(int tlId,
                       int pos,
                       int desId,
                       boolean light,
                       int tlNewId,
                       int posNew)
DOCUMENT ME!

Parameters:
tlId - DOCUMENT ME!
pos - DOCUMENT ME!
desId - DOCUMENT ME!
light - DOCUMENT ME!
tlNewId - DOCUMENT ME!
posNew - DOCUMENT ME!

recalcQ

protected void recalcQ(int tlId,
                       int pos,
                       int desId,
                       boolean light,
                       int tlNewId,
                       int posNew,
                       PosMov[] posMovs)
DOCUMENT ME!

Parameters:
tlId - DOCUMENT ME!
pos - DOCUMENT ME!
desId - DOCUMENT ME!
light - DOCUMENT ME!
tlNewId - DOCUMENT ME!
posNew - DOCUMENT ME!
posMovs - DOCUMENT ME!

recalcV

protected void recalcV(int tlId,
                       int pos,
                       int desId)
DOCUMENT ME!

Parameters:
tlId - DOCUMENT ME!
pos - DOCUMENT ME!
desId - DOCUMENT ME!

calcPGR

protected float[] calcPGR(int tlId,
                          int pos,
                          int desId)

rewardFunction

protected int rewardFunction(int tlId,
                             int pos,
                             int tlNewId,
                             int posNew)
DOCUMENT ME!

Parameters:
tlId - DOCUMENT ME!
pos - DOCUMENT ME!
tlNewId - DOCUMENT ME!
posNew - DOCUMENT ME!
Returns:
DOCUMENT ME!

getVValue

public float getVValue(Sign sign,
                       Node des,
                       int pos)
DOCUMENT ME!

Parameters:
sign - DOCUMENT ME!
des - DOCUMENT ME!
pos - DOCUMENT ME!
Returns:
DOCUMENT ME!

getColearnValue

public float getColearnValue(Sign now,
                             Sign sign,
                             Node des,
                             int pos)
DOCUMENT ME!

Specified by:
getColearnValue in interface Colearning
Parameters:
now - DOCUMENT ME!
sign - DOCUMENT ME!
des - DOCUMENT ME!
pos - DOCUMENT ME!
Returns:
DOCUMENT ME!

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!

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!

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!

getXMLName

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

Specified by:
getXMLName in interface XMLSerializable
Returns:
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!

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!