예제 #1
0
 public void saveChilds(XMLSaver saver)
     throws XMLTreeException, IOException, XMLCannotSaveException {
   super.saveChilds(saver);
   XMLArray.saveArray(q_table, this, saver, "q-table");
   // XMLArray.saveArray(v_table,this,saver,"v-table");
   XMLArray.saveArray(count, this, saver, "counts");
   // XMLArray.saveArray(p_table,this,saver,"p-table");
 }
예제 #2
0
 public void load(XMLElement myElement, XMLLoader loader)
     throws XMLTreeException, IOException, XMLInvalidInputException {
   super.load(myElement, loader);
   gamma = myElement.getAttribute("gamma").getFloatValue();
   random_chance = myElement.getAttribute("random-chance").getFloatValue();
   q_table = (float[][][][]) XMLArray.loadArray(this, loader);
   // v_table=(float[][][])XMLArray.loadArray(this,loader);
   count = (Vector) XMLArray.loadArray(this, loader, this);
   // p_table=(Vector)XMLArray.loadArray(this,loader,this);
 }
예제 #3
0
	public void loadSecondStage (Dictionary dictionaries) throws XMLInvalidInputException,XMLTreeException
	{ 	super.loadSecondStage(dictionaries);
		for(int i=0;i<count.length;i++)
					for(int j=0;j<count[i].length;j++)
						for(int k=0;k<count[i][j].length;k++)
							XMLUtils.loadSecondStage(count[i][j][k].elements(),dictionaries);		
		for(int i=0;i<p_table.length;i++)
					for(int j=0;j<p_table[i].length;j++)
						for(int k=0;k<p_table[i][j].length;k++)
							XMLUtils.loadSecondStage(p_table[i][j][k].elements(),dictionaries);		
		for(int i=0;i<pKtl_table.length;i++)
					for(int j=0;j<pKtl_table[i].length;j++)
						for(int k=0;k<pKtl_table[i][j].length;k++)
							XMLUtils.loadSecondStage(pKtl_table[i][j][k].elements(),dictionaries);		
		System.out.println("TC3 second stage load finished.");			
	}
예제 #4
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."); }
	}