@@ -51,21 +51,27 @@ public class UrbanSystem implements Serializable { |
ResourceSecurityOutput FuelRsrOutput; |
AggregatedResourceSecurityOutput AggWaterOutput; |
AggregatedResourceSecurityOutput AggFuelOutput; |
+ AggregatedResourceSecurityOutput AggElecOutput; |
FacilityStatusOutput FacilityStatus; |
- AggregatedFacilityStatusOutput AggFacilityStatus; |
-// AggregatedFacilityStatusOutput AggWaterFacilityStatus; |
-// AggregatedFacilityStatusOutput AggFuelFacilityStatus; |
+// AggregatedFacilityStatusOutput AggFacilityStatus; |
+ AggregatedFacilityStatusOutput AggWaterFacilityStatus; |
+ AggregatedFacilityStatusOutput AggFuelFacilityStatus; |
+ AggregatedFacilityStatusOutput Agg_ELEC_Initial; |
+ AggregatedFacilityStatusOutput Agg_WATER_Initial; |
|
public UrbanSystem(InfrastructureSystem I, Population P, RoadNetwork N, ActivityLocation AL, int time, int period) { |
- WaterRsrOutput = new ResourceSecurityOutput("Water"); |
- FuelRsrOutput = new ResourceSecurityOutput("Fuel"); |
+// WaterRsrOutput = new ResourceSecurityOutput("Water"); |
+// FuelRsrOutput = new ResourceSecurityOutput("Fuel"); |
AggWaterOutput = new AggregatedResourceSecurityOutput("Water"); |
AggFuelOutput = new AggregatedResourceSecurityOutput("Fuel"); |
- FacilityStatus = new FacilityStatusOutput(); |
- AggFacilityStatus = new AggregatedFacilityStatusOutput(); |
+ AggElecOutput = new AggregatedResourceSecurityOutput("Elec"); |
+// FacilityStatus = new FacilityStatusOutput(); |
+// AggFacilityStatus = new AggregatedFacilityStatusOutput(); |
SupplementaryTrips = new ArrayList<>(); |
-// AggWaterFacilityStatus = new AggregatedFacilityStatusOutput("Water"); |
-// AggFuelFacilityStatus = new AggregatedFacilityStatusOutput("Fuel"); |
+ AggWaterFacilityStatus = new AggregatedFacilityStatusOutput("Water"); |
+ AggFuelFacilityStatus = new AggregatedFacilityStatusOutput("Fuel"); |
+ Agg_ELEC_Initial = new AggregatedFacilityStatusOutput("Elec_Function"); |
+ Agg_WATER_Initial = new AggregatedFacilityStatusOutput("Water_Function"); |
this.RoadNetwork = N; |
this.Infrastructure = I; |
this.Population = P; |
@@ -80,21 +86,24 @@ public class UrbanSystem implements Serializable { |
assignHHIDandVHID(); |
estimateInfrastructureServiceCapacity(); |
buildFunctionalSupportToHousehold(); |
- initHouseholdState(AggWaterOutput, AggFuelOutput); |
- initFacilityState(AggFacilityStatus); |
-// initFacilityState(AggWaterFacilityStatus, AggFuelFacilityStatus); |
+ initHouseholdState(AggWaterOutput, AggFuelOutput, AggElecOutput); |
+// initFacilityState(AggFacilityStatus); |
+ initFacilityState(AggWaterFacilityStatus, AggFuelFacilityStatus); |
} |
|
public UrbanSystem(InfrastructureSystem I, Population P, RoadNetwork N, ActivityLocation AL, int time, int period, int i) { |
- WaterRsrOutput = new ResourceSecurityOutput("Water"); |
- FuelRsrOutput = new ResourceSecurityOutput("Fuel"); |
+// WaterRsrOutput = new ResourceSecurityOutput("Water"); |
+// FuelRsrOutput = new ResourceSecurityOutput("Fuel"); |
AggWaterOutput = new AggregatedResourceSecurityOutput("Water"); |
AggFuelOutput = new AggregatedResourceSecurityOutput("Fuel"); |
- FacilityStatus = new FacilityStatusOutput(); |
- AggFacilityStatus = new AggregatedFacilityStatusOutput(); |
+ AggElecOutput = new AggregatedResourceSecurityOutput("Elec"); |
+// FacilityStatus = new FacilityStatusOutput(); |
+// AggFacilityStatus = new AggregatedFacilityStatusOutput(); |
this.SupplementaryTrips = new ArrayList<>(); |
-// AggWaterFacilityStatus = new AggregatedFacilityStatusOutput("Water"); |
-// AggFuelFacilityStatus = new AggregatedFacilityStatusOutput("Fuel"); |
+ AggWaterFacilityStatus = new AggregatedFacilityStatusOutput("Water"); |
+ AggFuelFacilityStatus = new AggregatedFacilityStatusOutput("Fuel"); |
+ Agg_ELEC_Initial = new AggregatedFacilityStatusOutput("Elec_Function"); |
+ Agg_WATER_Initial = new AggregatedFacilityStatusOutput("Water_Function"); |
this.RoadNetwork = N; |
this.Infrastructure = I; |
this.Population = P; |
@@ -402,7 +411,6 @@ public class UrbanSystem implements Serializable { |
// this.Infrastructure.recordAggregatedFacilityStatus(this.SystemTime, this.AggFacilityStatus); |
// this.Infrastructure.recordFacilityStatus(this.SystemTime, this.FacilityStatus); |
// new_failed = new ArrayList<Integer>(); |
-// System.out.println(TF.Seconds2HMS(this.SystemTime)); |
} |
|
// For events within each time step, update the product inventory according to the refill |
@@ -472,54 +480,198 @@ public class UrbanSystem implements Serializable { |
} |
} |
} |
- for (String s : this.AggFacilityStatus.keySet()){ |
- int id = Integer.parseInt(s); |
- int[] temp = this.AggFacilityStatus.get(s); |
- int amount = 0; |
- if (unfulfilled_demand.containsKey(id)){ |
- amount = (int) (1000*unfulfilled_demand.get(id)); |
- } |
- temp[3] = this.SystemTime; |
- temp[4] = temp[4] + amount; |
- this.AggFacilityStatus.put(s, temp); |
- } |
-// for (String s : this.AggFuelFacilityStatus.keySet()){ |
+// for (String s : this.AggFacilityStatus.keySet()){ |
// int id = Integer.parseInt(s); |
-// int[] temp = this.AggFuelFacilityStatus.get(s); |
+// int[] temp = this.AggFacilityStatus.get(s); |
// int amount = 0; |
// if (unfulfilled_demand.containsKey(id)){ |
// amount = (int) (1000*unfulfilled_demand.get(id)); |
// } |
// temp[3] = this.SystemTime; |
// temp[4] = temp[4] + amount; |
-// this.AggFuelFacilityStatus.put(s, temp); |
-// } |
-// for (String s : this.AggWaterFacilityStatus.keySet()){ |
-// int id = Integer.parseInt(s); |
-// int[] temp = this.AggWaterFacilityStatus.get(s); |
-// int amount = 0; |
-// if (unfulfilled_demand.containsKey(id)){ |
-// amount = (int) (1000*unfulfilled_demand.get(id)); |
-// } |
-// temp[3] = this.SystemTime; |
-// temp[4] = temp[4] + amount; |
-// this.AggWaterFacilityStatus.put(s, temp); |
+// this.AggFacilityStatus.put(s, temp); |
// } |
+ for (String s : this.AggFuelFacilityStatus.keySet()){ |
+ int id = Integer.parseInt(s); |
+ int[] temp = this.AggFuelFacilityStatus.get(s); |
+ int amount = 0; |
+ if (unfulfilled_demand.containsKey(id)){ |
+ amount = (int) (1000*unfulfilled_demand.get(id)); |
+ } |
+ temp[3] = this.SystemTime; |
+ temp[4] = temp[4] + amount; |
+ this.AggFuelFacilityStatus.put(s, temp); |
+ } |
+ for (String s : this.AggWaterFacilityStatus.keySet()){ |
+ int id = Integer.parseInt(s); |
+ int[] temp = this.AggWaterFacilityStatus.get(s); |
+ int amount = 0; |
+ if (unfulfilled_demand.containsKey(id)){ |
+ amount = (int) (1000*unfulfilled_demand.get(id)); |
+ } |
+ temp[3] = this.SystemTime; |
+ temp[4] = temp[4] + amount; |
+ this.AggWaterFacilityStatus.put(s, temp); |
+ } |
+ |
+ // Household level output |
for (String s : this.AggWaterOutput.keySet()){ |
+ Household h = this.Population.get(Integer.parseInt(s)); |
int[] infor_water = this.AggWaterOutput.get(s); |
int[] infor_fuel = this.AggFuelOutput.get(s); |
+ |
if (infor_water[2] == 0){ |
- infor_water[4] += this.SystemTime - infor_water[3]; |
+ infor_water[4] += (int)((this.SystemTime - infor_water[3])/3.6*h.ConsumptionRate[1]); |
} |
infor_water[3] = this.SystemTime; |
this.AggWaterOutput.put(s, infor_water); |
|
if (infor_fuel[2] == 0){ |
- infor_fuel[4] += this.SystemTime - infor_fuel[3]; |
+ infor_fuel[4] += (int)((this.SystemTime - infor_fuel[3])/3.6*h.ConsumptionRate[2]); |
} |
infor_fuel[3] = this.SystemTime; |
this.AggFuelOutput.put(s, infor_fuel); |
} |
+ |
+ // Aggregate the effect of three levels of water output |
+ if (! this.Agg_WATER_Initial.isEmpty()){ |
+ for (String s : this.Agg_WATER_Initial.keySet()){ |
+ int id = Integer.parseInt(s); |
+ int type = id/10000; |
+ if (type == GE.WATER_TANK){ |
+ Facility f = this.Infrastructure.get(id); |
+ int[] temp_in = this.Agg_WATER_Initial.get(s); |
+ int amount = 0; |
+ for (Integer i : f.FunctionalSupportHousehold){ |
+ int[] infor = this.AggWaterOutput.get(Integer.toString(i)); |
+ amount = amount + infor[4]; |
+ } |
+ temp_in[3] = this.SystemTime; |
+ temp_in[4] = temp_in[4] + amount; |
+ this.Agg_WATER_Initial.put(s, temp_in); |
+ } |
+ } |
+ for (String s : this.Agg_WATER_Initial.keySet()){ |
+ int id = Integer.parseInt(s); |
+ int type = id/10000; |
+ if (type == GE.WATER_TOWER){ |
+ Facility f = this.Infrastructure.get(id); |
+ int[] temp_in = this.Agg_WATER_Initial.get(s); |
+ int amount = 0; |
+ for (Integer i : f.FunctionalSupportHousehold){ |
+ int[] infor = this.AggWaterOutput.get(Integer.toString(i)); |
+ amount = amount + infor[4]; |
+ } |
+ for (Integer i : f.FunctionalSupportFacility){ |
+ if (i != 0){ |
+ int[] infor = this.Agg_WATER_Initial.get(Integer.toString(i)); |
+ amount = amount + infor[4]; |
+ } |
+ } |
+ temp_in[3] = this.SystemTime; |
+ temp_in[4] = temp_in[4] + amount; |
+ this.Agg_WATER_Initial.put(s, temp_in); |
+ } |
+ } |
+ for (String s : this.Agg_WATER_Initial.keySet()){ |
+ int id = Integer.parseInt(s); |
+ int type = id/10000; |
+ if (type == GE.WATER_PLANT){ |
+ Facility f = this.Infrastructure.get(id); |
+ int[] temp_in = this.Agg_WATER_Initial.get(s); |
+ int amount = 0; |
+ for (Integer i : f.FunctionalSupportHousehold){ |
+ int[] infor = this.AggWaterOutput.get(Integer.toString(i)); |
+ amount = amount + infor[4]; |
+ } |
+ for (Integer i : f.FunctionalSupportFacility){ |
+ if (i != 0){ |
+ int[] infor = this.Agg_WATER_Initial.get(Integer.toString(i)); |
+ amount = amount + infor[4]; |
+ } |
+ } |
+ temp_in[3] = this.SystemTime; |
+ temp_in[4] = temp_in[4] + amount; |
+ this.Agg_WATER_Initial.put(s, temp_in); |
+ } |
+ } |
+ } |
+ |
+ // Aggregate the effect of three levels of electricity output |
+ if (! this.Agg_ELEC_Initial.isEmpty()){ |
+ for (String s : this.Agg_ELEC_Initial.keySet()){ |
+ int id = Integer.parseInt(s); |
+ int type = id/10000; |
+ if (type == GE.POWER_TRANSFORMER){ |
+ Facility f = this.Infrastructure.get(id); |
+ int[] temp_in = this.Agg_ELEC_Initial.get(s); |
+ int amount = 0; |
+ for (Integer i : f.FunctionalSupportFacility){ |
+ if (this.Agg_WATER_Initial.containsKey(Integer.toString(i))){ |
+ amount = amount + this.Agg_WATER_Initial.get(Integer.toString(i))[4]; |
+ }else{ |
+ amount = amount + this.AggWaterFacilityStatus.get(Integer.toString(i))[4]; |
+ } |
+ } |
+ temp_in[3] = this.SystemTime; |
+ temp_in[4] = temp_in[4] + amount; |
+ this.Agg_ELEC_Initial.put(s, temp_in); |
+ for (Integer j : f.FunctionalSupportHousehold){ |
+ int[] hh = this.AggElecOutput.get(Integer.toString(j)); |
+ hh[4] += this.AnalysisPeriod; |
+ this.AggElecOutput.put(Integer.toString(j), hh); |
+ } |
+ } |
+ } |
+ for (String s : this.Agg_ELEC_Initial.keySet()){ |
+ int id = Integer.parseInt(s); |
+ int type = id/10000; |
+ if (type == GE.POWER_SUBSTATION){ |
+ Facility f = this.Infrastructure.get(id); |
+ int[] temp_in = this.Agg_ELEC_Initial.get(s); |
+ int amount = 0; |
+ for (Integer i : f.FunctionalSupportFacility){ |
+ if (i/1000000 == GE.WATERCODE){ |
+ if (this.Agg_WATER_Initial.containsKey(Integer.toString(i))){ |
+ amount = amount + this.Agg_WATER_Initial.get(Integer.toString(i))[4]; |
+ }else{ |
+ amount = amount + this.AggWaterFacilityStatus.get(Integer.toString(i))[4]; |
+ } |
+ }else{ |
+ amount = amount + this.Agg_ELEC_Initial.get(Integer.toString(i))[4]; |
+ } |
+ } |
+ temp_in[3] = this.SystemTime; |
+ temp_in[4] = temp_in[4] + amount; |
+ this.Agg_ELEC_Initial.put(s, temp_in); |
+ } |
+ } |
+ for (String s : this.Agg_ELEC_Initial.keySet()){ |
+ int id = Integer.parseInt(s); |
+ int type = id/10000; |
+ if (type == GE.POWER_PYLON){ |
+ Facility f = this.Infrastructure.get(id); |
+ int[] temp_in = this.Agg_ELEC_Initial.get(s); |
+ int amount = 0; |
+ for (Integer i : f.FunctionalSupportFacility){ |
+ if (i/1000000 == GE.WATERCODE){ |
+ if (this.Agg_WATER_Initial.containsKey(Integer.toString(i))){ |
+ amount = amount + this.Agg_WATER_Initial.get(Integer.toString(i))[4]; |
+ }else{ |
+ amount = amount + this.AggWaterFacilityStatus.get(Integer.toString(i))[4]; |
+ } |
+ }else{ |
+ amount = amount + this.Agg_ELEC_Initial.get(Integer.toString(i))[4]; |
+ } |
+ } |
+ temp_in[3] = this.SystemTime; |
+ temp_in[4] = temp_in[4] + amount; |
+ this.Agg_ELEC_Initial.put(s, temp_in); |
+ } |
+ } |
+ } |
+ |
+ |
System.out.println("Post TRANSIMS simulation complete."); |
} |
|
@@ -1010,7 +1162,7 @@ public class UrbanSystem implements Serializable { |
|
} |
|
- public void systemDisruption(String file_name) throws FileNotFoundException, IOException { |
+ public void systemDisruption(String file_name, AggregatedFacilityStatusOutput A, AggregatedFacilityStatusOutput B) throws FileNotFoundException, IOException { |
|
GeneralParameterNEncoding GE = new GeneralParameterNEncoding(); |
int id; |
@@ -1057,8 +1209,6 @@ public class UrbanSystem implements Serializable { |
if (f.Status != 0){ |
failed_list.add(X); |
} |
- } else { |
- System.out.println(X + " is not a valid facility ID."); |
} |
} |
if (! failed_list.isEmpty()){ |
@@ -1069,18 +1219,37 @@ public class UrbanSystem implements Serializable { |
temp = this.DisruptedFacilities.get(id / 1000000); |
tempx = this.DisruptedFacilitiesX.get(id / 1000000); |
tempy = this.DisruptedFacilitiesY.get(id / 1000000); |
- temp.add(id); |
- tempx.add(this.Infrastructure.getFacility(id).Location[0]); |
- tempy.add(this.Infrastructure.getFacility(id).Location[1]); |
+ Facility f = this.Infrastructure.getFacility(id); |
+ tempx.add(f.Location[0]); |
+ tempy.add(f.Location[1]); |
this.DisruptedFacilities.put(id / 1000000, temp); |
this.DisruptedFacilitiesX.put(id / 1000000, tempx); |
this.DisruptedFacilitiesY.put(id / 1000000, tempy); |
+ if (f.Type/100 == GE.ELECCODE){ |
+ int[] fac_statues = new int[5]; |
+ fac_statues[0] = f.Location[0]; |
+ fac_statues[1] = f.Location[1]; |
+ fac_statues[2] = f.Status; |
+ fac_statues[3] = 0; |
+ fac_statues[4] = 0; |
+ A.put(Integer.toString(f.ID), fac_statues); |
+ }else if (f.Type/100 == GE.WATERCODE){ |
+ int[] fac_statues = new int[5]; |
+ fac_statues[0] = f.Location[0]; |
+ fac_statues[1] = f.Location[1]; |
+ fac_statues[2] = f.Status; |
+ fac_statues[3] = 0; |
+ fac_statues[4] = 0; |
+ B.put(Integer.toString(f.ID), fac_statues); |
+ } |
temp = new ArrayList<Integer>(); |
} |
for (Integer m : this.DisruptedFacilities.keySet()){ |
this.DisruptedOutputX.put(m, arraylist_toArray(this.DisruptedFacilitiesX.get(m))); |
this.DisruptedOutputY.put(m, arraylist_toArray(this.DisruptedFacilitiesY.get(m))); |
} |
+ |
+ |
// this.determineHouseholdLostElec(this.SystemTime, this.ElecRsrOutput, this.Infrastructure, this.Population, this.DisruptedFacilities) |
} |
} |
@@ -1097,7 +1266,7 @@ public class UrbanSystem implements Serializable { |
return output; |
} |
|
- public void systemRecover(String file_name) throws FileNotFoundException, IOException{ |
+ public void systemRecover(String file_name, AggregatedFacilityStatusOutput A, AggregatedFacilityStatusOutput B) throws FileNotFoundException, IOException{ |
GeneralParameterNEncoding GE = new GeneralParameterNEncoding(); |
this.RecoveryOutputX = new HashMap<>(); |
this.RecoveryOutputX.put(GE.WATERCODE, new int[]{}); |
@@ -1135,8 +1304,6 @@ public class UrbanSystem implements Serializable { |
Integer X = Integer.parseInt(splitline[0]); |
if (this.isFacility(X)) { |
recovery_list.add(X); |
- } else { |
- System.out.println(X + " is not a valid facility ID."); |
} |
} |
if (! recovery_list.isEmpty()){ |
@@ -1148,12 +1315,18 @@ public class UrbanSystem implements Serializable { |
tempx = this.RecoveryFacilitiesX.get(id / 1000000); |
tempy = this.RecoveryFacilitiesY.get(id / 1000000); |
temp.add(id); |
- tempx.add(this.Infrastructure.getFacility(id).Location[0]); |
- tempy.add(this.Infrastructure.getFacility(id).Location[1]); |
+ Facility f = this.Infrastructure.getFacility(id); |
+ tempx.add(f.Location[0]); |
+ tempy.add(f.Location[1]); |
this.RecoveryFacilities.put(id / 1000000, temp); |
this.RecoveryFacilitiesX.put(id / 1000000, tempx); |
this.RecoveryFacilitiesY.put(id / 1000000, tempy); |
temp = new ArrayList<Integer>(); |
+ if (f.Type/100 == GE.ELECCODE){ |
+ A.remove(Integer.toString(f.ID)); |
+ }else if (f.Type/100 == GE.WATERCODE){ |
+ B.remove(Integer.toString(f.ID)); |
+ } |
} |
for (Integer m : this.RecoveryFacilities.keySet()){ |
this.RecoveryOutputX.put(m, arraylist_toArray(this.RecoveryFacilitiesX.get(m))); |
@@ -1163,38 +1336,38 @@ public class UrbanSystem implements Serializable { |
} |
} |
|
- private void initFacilityState(AggregatedFacilityStatusOutput fac_output) { |
-// GeneralParameterNEncoding GE = new GeneralParameterNEncoding(); |
+ private void initFacilityState(AggregatedFacilityStatusOutput fac_output, AggregatedFacilityStatusOutput fac_output_2) { |
+ GeneralParameterNEncoding GE = new GeneralParameterNEncoding(); |
int[] fac_statues; |
-// int type_1, type_2; |
-// if (fac_output.ResourceType == "Water"){ |
-// type_1 = GE.WATERCODE; |
-// type_2 = GE.FUELCODE; |
-// }else{ |
-// type_1 = GE.FUELCODE; |
-// type_2 = GE.WATERCODE; |
-// } |
+ int type_1, type_2; |
+ if (fac_output.ResourceType == "Water"){ |
+ type_1 = GE.WATERCODE; |
+ type_2 = GE.FUELCODE; |
+ }else{ |
+ type_1 = GE.FUELCODE; |
+ type_2 = GE.WATERCODE; |
+ } |
|
Iterator<Facility> I = this.Infrastructure.iterator(); |
while(I.hasNext()) { |
Facility f = I.next(); |
-// if (f.Type/100 == type_1){ |
- fac_statues = new int[5]; |
- fac_statues[0] = f.Location[0]; |
- fac_statues[1] = f.Location[1]; |
- fac_statues[2] = f.Status; |
- fac_statues[3] = 0; |
- fac_statues[4] = 0; |
- fac_output.put(Integer.toString(f.ID), fac_statues); |
-// }else if (f.Type/100 == type_2){ |
-// fac_statues = new int[5]; |
-// fac_statues[0] = f.Location[0]; |
-// fac_statues[1] = f.Location[1]; |
-// fac_statues[2] = f.Status; |
-// fac_statues[3] = 0; |
-// fac_statues[4] = 0; |
-// fac_output_2.put(Integer.toString(f.ID), fac_statues); |
-// } |
+ if (f.Type/100 == type_1){ |
+ fac_statues = new int[5]; |
+ fac_statues[0] = f.Location[0]; |
+ fac_statues[1] = f.Location[1]; |
+ fac_statues[2] = f.Status; |
+ fac_statues[3] = 0; |
+ fac_statues[4] = 0; |
+ fac_output.put(Integer.toString(f.ID), fac_statues); |
+ }else if (f.Type/100 == type_2){ |
+ fac_statues = new int[5]; |
+ fac_statues[0] = f.Location[0]; |
+ fac_statues[1] = f.Location[1]; |
+ fac_statues[2] = f.Status; |
+ fac_statues[3] = 0; |
+ fac_statues[4] = 0; |
+ fac_output_2.put(Integer.toString(f.ID), fac_statues); |
+ } |
} |
} |
|
@@ -1202,9 +1375,8 @@ public class UrbanSystem implements Serializable { |
this.Infrastructure.writeFacilityStatus(file_name); |
} |
|
- private void initHouseholdState(AggregatedResourceSecurityOutput water_rs_output, AggregatedResourceSecurityOutput fuel_rs_output) { |
+ private void initHouseholdState(AggregatedResourceSecurityOutput water_rs_output, AggregatedResourceSecurityOutput fuel_rs_output, AggregatedResourceSecurityOutput elec) { |
int[] hh_water_infor; |
- int[] hh_fuel_infor; |
|
ArrayList<Integer> HHconsumesWater = this.Population.recordHouseholdIDs; |
|
@@ -1218,21 +1390,8 @@ public class UrbanSystem implements Serializable { |
hh_water_infor[3] = 0; // This is the current time |
hh_water_infor[4] = 0; // This is the total delay to wait for that material |
water_rs_output.put(Integer.toString(h.ID), hh_water_infor); |
- |
- } |
- |
- ArrayList<Integer> HHconsumesFuel = this.Population.recordHouseholdIDs; |
- |
- Iterator<Integer> IF = HHconsumesFuel.iterator(); |
- while (IF.hasNext()) { |
- Household h = this.Population.get(IF.next()); |
- hh_fuel_infor = new int[5]; |
- hh_fuel_infor[0] = h.Location[0]; |
- hh_fuel_infor[1] = h.Location[1]; |
- hh_fuel_infor[2] = 1; |
- hh_fuel_infor[3] = 0; |
- hh_fuel_infor[4] = 0; |
- fuel_rs_output.put(Integer.toString(h.ID), hh_fuel_infor); |
+ fuel_rs_output.put(Integer.toString(h.ID), hh_water_infor); |
+ elec.put(Integer.toString(h.ID), hh_water_infor); |
} |
} |
|
@@ -1293,10 +1452,6 @@ public class UrbanSystem implements Serializable { |
InputStream inputFS = new FileInputStream(inputF); |
BufferedReader br = new BufferedReader(new InputStreamReader(inputFS)); |
String line = br.readLine(); |
-// this.maxHHID = Integer.parseInt(line.split(",")[0]); |
-// this.maxVHID = Integer.parseInt(line.split(",")[1]); |
-// System.out.println("Max_HHID: " + Integer.toString(maxHHID)); |
-// System.out.println("Max_VHID: " + Integer.toString(maxVHID)); |
int max_hhid = 0; |
while((line = br.readLine()) != null){ |
String[] splitline = line.split(":"); |
@@ -1393,100 +1548,40 @@ public class UrbanSystem implements Serializable { |
} |
} |
|
- public void WriteResultFiles(String loc, int t) throws IOException{ |
- System.out.println("Writing resoutce security output to file."); |
- String casename = "Output_Water.txt"; |
+ public void WriteFUnctionalFailure(String loc, String casename, AggregatedFacilityStatusOutput A) throws IOException { |
String results_file_loc = loc + casename; |
File vehicle_file = new File(results_file_loc); |
FileWriter vf_writer = new FileWriter(vehicle_file); |
List<String> vh_file_records = new ArrayList<String>(); |
- |
- String casename1 = "Output_Fuel.txt"; |
- String results_file_loc1 = loc + casename1; |
- File vehicle_file1 = new File(results_file_loc1); |
- FileWriter vf_writer1 = new FileWriter(vehicle_file1); |
- List<String> vh_file_records1 = new ArrayList<String>(); |
- |
- String casename2 = "Output_Facility.txt"; |
- String results_file_loc2 = loc + casename2; |
- File vehicle_file2 = new File(results_file_loc2); |
- FileWriter vf_writer2 = new FileWriter(vehicle_file2); |
- List<String> vh_file_records2 = new ArrayList<String>(); |
- |
-// String casename2 = "Output_Water_Facility.txt"; |
-// String results_file_loc2 = loc + casename2; |
-// File vehicle_file2 = new File(results_file_loc2); |
-// FileWriter vf_writer2 = new FileWriter(vehicle_file2); |
-// List<String> vh_file_records2 = new ArrayList<String>(); |
- |
-// String casename3 = "Output_Fuel_Facility.txt"; |
-// String results_file_loc3 = loc + casename3; |
-// File vehicle_file3 = new File(results_file_loc3); |
-// FileWriter vf_writer3 = new FileWriter(vehicle_file3); |
-// List<String> vh_file_records3 = new ArrayList<String>(); |
- |
- vh_file_records.add("ID\tLocation_X\tLocation_Y\tCurrentState\tResourceLostTime\tCurrentTime\n"); |
- Iterator<String> I = this.AggWaterOutput.keySet().iterator(); |
- while(I.hasNext()){ |
+ vh_file_records.add("ID\tLocation_X\tLocation_Y\tCurrentState\tCurrentTime\tResourceLostTime\n"); |
+ Iterator<String> I = A.keySet().iterator(); |
+ while (I.hasNext()) { |
String id = I.next(); |
- int[] infor = this.AggWaterOutput.get(id); |
+ int[] infor = A.get(id); |
vh_file_records.add(id + "\t" + infor[0] + "\t" + infor[1] + "\t" + infor[2] + "\t" + infor[3] + "\t" + infor[4] + "\n"); |
} |
- for (String record: vh_file_records) { |
+ for (String record : vh_file_records) { |
vf_writer.write(record); |
} |
vf_writer.close(); |
+ } |
|
- vh_file_records1.add("ID\tLocation_X\tLocation_Y\tCurrentState\tResourceLostTime\tCurrentTime\n"); |
- Iterator<String> II = this.AggFuelOutput.keySet().iterator(); |
- while(II.hasNext()){ |
- String id = II.next(); |
- int[] infor = this.AggFuelOutput.get(id); |
- vh_file_records1.add(id + "\t" + infor[0] + "\t" + infor[1] + "\t" + infor[2] + "\t" + infor[3] + "\t" + infor[4] + "\n"); |
- } |
- for (String record: vh_file_records1) { |
- vf_writer1.write(record); |
- } |
- vf_writer1.close(); |
- |
- vh_file_records2.add("ID\tLocation_X\tLocation_Y\tCurrentState\tResourceLostTime\tCurrentTime\n"); |
- Iterator<String> III = this.AggFacilityStatus.keySet().iterator(); |
- while(III.hasNext()){ |
- String id = III.next(); |
- int[] infor = this.AggFacilityStatus.get(id); |
- vh_file_records2.add(id + "\t" + infor[0] + "\t" + infor[1] + "\t" + infor[2] + "\t" + infor[3] + "\t" + infor[4] + "\n"); |
+ public void WriteHHShortage(String loc, String casename, AggregatedResourceSecurityOutput A) throws IOException { |
+ String results_file_loc = loc + casename; |
+ File vehicle_file = new File(results_file_loc); |
+ FileWriter vf_writer = new FileWriter(vehicle_file); |
+ List<String> vh_file_records = new ArrayList<String>(); |
+ vh_file_records.add("ID\tLocation_X\tLocation_Y\tCurrentState\tCurrentTime\tResourceLostTime\n"); |
+ Iterator<String> I = A.keySet().iterator(); |
+ while (I.hasNext()) { |
+ String id = I.next(); |
+ int[] infor = A.get(id); |
+ vh_file_records.add(id + "\t" + infor[0] + "\t" + infor[1] + "\t" + infor[2] + "\t" + infor[3] + "\t" + infor[4] + "\n"); |
} |
- for (String record: vh_file_records2) { |
- vf_writer2.write(record); |
+ for (String record : vh_file_records) { |
+ vf_writer.write(record); |
} |
- vf_writer2.close(); |
- |
-// vh_file_records2.add("ID\tLocation_X\tLocation_Y\tCurrentState\tResourceLostTime\tCurrentTime\n"); |
-// Iterator<String> III = this.AggWaterFacilityStatus.keySet().iterator(); |
-// while(III.hasNext()){ |
-// String id = III.next(); |
-// int[] infor = this.AggWaterFacilityStatus.get(id); |
-// vh_file_records2.add(id + "\t" + infor[0] + "\t" + infor[1] + "\t" + infor[2] + "\t" + infor[3] + "\t" + infor[4] + "\n"); |
-// } |
-// for (String record: vh_file_records2) { |
-// vf_writer2.write(record); |
-// } |
-// vf_writer2.close(); |
-// |
-// vh_file_records3.add("ID\tLocation_X\tLocation_Y\tCurrentState\tResourceLostTime\tCurrentTime\n"); |
-// Iterator<String> IV = this.AggFuelFacilityStatus.keySet().iterator(); |
-// while(IV.hasNext()){ |
-// String id = IV.next(); |
-// int[] infor = this.AggFuelFacilityStatus.get(id); |
-// vh_file_records3.add(id + "\t" + infor[0] + "\t" + infor[1] + "\t" + infor[2] + "\t" + infor[3] + "\t" + infor[4] + "\n"); |
-// } |
-// for (String record: vh_file_records3) { |
-// vf_writer3.write(record); |
-// } |
-// vf_writer3.close(); |
- |
- System.out.println("Write resource security output files FINISHED."); |
+ vf_writer.close(); |
} |
- |
} |
|