public int[] makeBuildOrderArray(int i) {

		double[] percentage_to_use = new double[FacilityHierarchy[i].length];
		double[] how_often_to_add=new double[FacilityHierarchy[i].length];
		double[] current_queue=new double[FacilityHierarchy[i].length];
		double next_up;
		int the_next_one;
		double norm = 0.;
		int[] the_order = new int[200];
		int j,k;

		for(j=0; j<FacilityHierarchy[i].length; j++) {
			percentage_to_use[j]=FacilityPercentage[i][j]/PLANT_SIZE[FacilityHierarchy[i][j]];
			norm+=percentage_to_use[j];
		}
		for(j=0; j<percentage_to_use.length; j++) {
			percentage_to_use[j]=percentage_to_use[j]/norm;
		}
		for(j=0; j<percentage_to_use.length; j++) {
			how_often_to_add[j]=1./percentage_to_use[j];
			current_queue[j]=how_often_to_add[j];
		}
		for(j=0; j<the_order.length; j++) {
			the_next_one=-1;
			next_up=1.e6;
			for(k=0; k<percentage_to_use.length; k++) {
				if(current_queue[k] < next_up) {
					the_next_one=k;
					next_up=current_queue[k];
				}
			}
			the_order[j]=FacilityHierarchy[i][the_next_one];
			current_queue[the_next_one]+=how_often_to_add[the_next_one];
			for(k=0; k<percentage_to_use.length; k++) {
				current_queue[k]-=1.;
			}
		}
		return(the_order);
	}