예제 #1
0
  /**
   * The constructor for TL controllers
   *
   * @param The model being used.
   */
  public SL1TLC(Infrastructure infra) throws InfraException {
    super(infra);
    Node[] nodes =
        infra.getAllNodes(); // Moet Edge zijn eigenlijk, alleen testSimModel knalt er dan op
    int num_nodes = nodes.length;

    count = new Vector();

    int numSigns = infra.getAllInboundLanes().size();
    q_table = new float[numSigns + 1][][][];
    int num_specialnodes = infra.getNumSpecialNodes();
    for (int i = 0; i < nodes.length; i++) {
      Node n = nodes[i];
      Drivelane[] dls = n.getInboundLanes();
      for (int j = 0; j < dls.length; j++) {
        Drivelane d = dls[j];
        Sign s = d.getSign();
        int id = s.getId();
        int num_pos_on_dl = d.getCompleteLength();
        q_table[id] = new float[num_pos_on_dl][][];
        for (int k = 0; k < num_pos_on_dl; k++) {
          q_table[id][k] = new float[num_specialnodes][];
          for (int l = 0; l < q_table[id][k].length; l++) {
            q_table[id][k][l] = new float[2];
            q_table[id][k][l][0] = 0.0f;
            q_table[id][k][l][1] = 0.0f;
          }
        }
      }
    }
    System.out.println("Startet med Alpha = " + alpha);

    random_number = new Random();
  }
예제 #2
0
	public void setInfrastructure( Infrastructure infra )
	{	super.setInfrastructure(infra);
	
		Node[] nodes = infra.getAllNodes();
		num_nodes = nodes.length;
	
		try{
			int numSigns = infra.getAllInboundLanes().size();
		
			q_table 	= new float [numSigns][][][];
			qa_table	= new float [numSigns][][][];
			v_table 	= new float [numSigns][][];
			va_table	= new float [numSigns][][];
			count		= new Vector[numSigns][][];
			p_table 	= new Vector[numSigns][][];
			pKtl_table	= new Vector[numSigns][][];
			
			int num_specialnodes = infra.getNumSpecialNodes();

			for (int i=0; i<num_nodes; i++) {
				Node n = nodes[i];
				Drivelane[] dls = dls = n.getInboundLanes();
				int num_dls = num_dls = dls.length;
				// huh?
				Drivelane [] lanes = new Drivelane[numSigns];
				infra.getAllInboundLanes().copyInto(lanes);
				
				for (int j=0; j<num_dls; j++) {
					Drivelane d = dls[j];
					Sign s = d.getSign();
					int id = d.getId();
					int num_pos_on_dl = d.getCompleteLength();

					q_table[id]		= new float [num_pos_on_dl][][];
					qa_table[id]	= new float [num_pos_on_dl][][];
					v_table[id]		= new float [num_pos_on_dl][];
					va_table[id]	= new float [num_pos_on_dl][];
					count[id]		= new Vector[num_pos_on_dl][];
					p_table[id]		= new Vector[num_pos_on_dl][];
					pKtl_table[id]	= new Vector[num_pos_on_dl][];
					
					for (int k=0; k<num_pos_on_dl; k++) {
						q_table[id][k]	= new float[num_specialnodes][2];
						qa_table[id][k]	= new float[num_specialnodes][2];
						v_table[id][k]	= new float[num_specialnodes];
						va_table[id][k]	= new float[num_specialnodes];
						count[id][k]	= new Vector[num_specialnodes];
						p_table[id][k]	= new Vector[num_specialnodes];
						pKtl_table[id][k] =  new Vector[num_specialnodes];
						
						for (int l=0; l<num_specialnodes;l++) {
							q_table[id][k][l][0]	= 0.0f;
							q_table[id][k][l][1]	= 0.0f;
							qa_table[id][k][l][0]	= 0.0f;
							qa_table[id][k][l][1]	= 0.0f;
							v_table[id][k][l]		= 0.0f;
							va_table[id][k][l]		= 0.0f;
							count[id][k][l]			= new Vector();
							p_table[id][k][l]		= new Vector();
							pKtl_table[id][k][l]	= new Vector();
						}
					}
				}
			} 
			random_number = new Random();
		}
		catch(Exception e) { System.out.println("Error."); }
	}