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

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

public class TC1B1
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 Bucketed Now Optimized 2.0


Nested Class Summary
 class TC1B1.CountEntry
           
 class TC1B1.PEntry
          DOCUMENT ME!
protected  class TC1B1.Target
          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 static int BUCK
          DOCUMENT ME!
protected  float[][] bucket
          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[][][] p_table
          DOCUMENT ME!
protected  float[][][][] q_table
          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[][][] v_table
          DOCUMENT ME!
protected static int WAIT
          DOCUMENT ME!
 
Fields inherited from class org.jscience.architecture.traffic.algorithms.tlc.TLController
infra, num_tls, tld, trackNode
 
Constructor Summary
TC1B1(Infrastructure infra)
          The constructor for TL controllers
 
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 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  float[] oldCalcPGR(int tlId, int pos, int desId)
           
protected  void recalcP(int tlId, int pos, int desId, boolean light, int tlNewId, int posNew)
           
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  void relaxBucket(int laneId, int prevpos)
          Empties the 'gain-value' bucket partly, which is being filled when Roadusers are waiting/voting for their TrafficLight to be set to green.
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!
protected  void siphonGainToOtherBucket(Drivelane here, Drivelane there)
          When a Roaduser may drive according to it's Sign, but cant as the desired Drivelane is full, (some/all) of the current gain-bucket of it's current TrafficLight is siphoned over to the desired Drivelane, making it more probable that that lane will move, making it possible for this Drivelane to move.
 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

BUCK

protected static int BUCK
DOCUMENT ME!


WAIT

protected static int WAIT
DOCUMENT ME!


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!


bucket

protected float[][] bucket
DOCUMENT ME!


count

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


p_table

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


q_table

protected float[][][][] q_table
DOCUMENT ME!


v_table

protected float[][][] v_table
DOCUMENT ME!

Constructor Detail

TC1B1

public TC1B1(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!

relaxBucket

protected void relaxBucket(int laneId,
                           int prevpos)
Empties the 'gain-value' bucket partly, which is being filled when Roadusers are waiting/voting for their TrafficLight to be set to green.

Parameters:
laneId - The Drivelane the Roaduser was on just before.
prevpos - DOCUMENT ME!

siphonGainToOtherBucket

protected void siphonGainToOtherBucket(Drivelane here,
                                       Drivelane there)
When a Roaduser may drive according to it's Sign, but cant as the desired Drivelane is full, (some/all) of the current gain-bucket of it's current TrafficLight is siphoned over to the desired Drivelane, making it more probable that that lane will move, making it possible for this Drivelane to move.

Parameters:
here - the Id of the drivelane the Roaduser is waiting at
there - the Id of the drivelane where the Roaduser wants to go now

recalcP

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

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!

oldCalcPGR

protected float[] oldCalcPGR(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!