public void startActivity(final ActivityOptionImpl activity, final BufferedWriter out) throws IOException { out.write("\t\t<activity"); out.write(" type=\"" + activity.getType() + "\""); out.write(">\n"); }
private final void combine(ActivityFacility f,ActivityFacilityImpl f2) { System.out.println(" Combining f_id=" + f.getId() + " into f2_id=" + f2.getId()); Iterator<? extends ActivityOption> a_it = f.getActivityOptions().values().iterator(); while (a_it.hasNext()) { ActivityOptionImpl a = (ActivityOptionImpl) a_it.next(); if (f2.getActivityOptions().get(a.getType()) == null) { ActivityOptionImpl a2 = f2.createAndAddActivityOption(a.getType()); a2.setCapacity(a.getCapacity()); } else { ActivityOptionImpl a2 = (ActivityOptionImpl) f2.getActivityOptions().get(a.getType()); double cap2 = a2.getCapacity(); double cap = a.getCapacity(); if ((cap < Integer.MAX_VALUE) && (cap2 < Integer.MAX_VALUE)) { a2.setCapacity(cap + cap2); } else { a2.setCapacity(Integer.MAX_VALUE); } } SortedSet<OpeningTime> ts = a.getOpeningTimes(); Iterator<OpeningTime> o_it = ts.iterator(); while (o_it.hasNext()) { OpeningTime o = o_it.next(); f2.getActivityOptions().get(a.getType()).addOpeningTime(o); } } if (Integer.parseInt(f2.getId().toString()) > Integer.parseInt(f.getId().toString())) { System.out.println(" => assigning f_id="+f.getId()+" to f2."); throw new RuntimeException("Can't set ids anymore."); } }
act_cnt++; if (a.getCapacity() != Integer.MAX_VALUE) { if (a.getType().equals("home")) { caps[0] += a.getCapacity(); else if (a.getType().equals("work")) { caps[1] += a.getCapacity(); else if (a.getType().equals("education")) { caps[2] += a.getCapacity(); else if (a.getType().equals("shop")) { caps[3] += a.getCapacity(); else if (a.getType().equals("leisure")) { caps[4] += a.getCapacity(); throw new RuntimeException("ERROR: in " + this.getClass().getName() + " in run(Facilities facilities):" + " do not know type = " + a.getType());
while (a_it.hasNext()) { ActivityOptionImpl a = (ActivityOptionImpl) a_it.next(); if (a.getType().equals("home")) { a.setCapacity(this.nof_persons/home_cnt); a.addOpeningTime(new OpeningTimeImpl(TIME_0000, TIME_2400)); else if (a.getType().equals("work")) { a.setCapacity(this.nof_persons/work_cnt); a.addOpeningTime(new OpeningTimeImpl(TIME_0800, TIME_1800)); else if (a.getType().equals("education")) { a.setCapacity(this.nof_persons/educ_cnt); a.addOpeningTime(new OpeningTimeImpl(TIME_0800, TIME_1200)); a.addOpeningTime(new OpeningTimeImpl(TIME_1300, TIME_1700)); else if (a.getType().equals("shop")) { a.setCapacity(this.nof_persons/shop_cnt); a.addOpeningTime(new OpeningTimeImpl(TIME_0830, TIME_1200)); a.addOpeningTime(new OpeningTimeImpl(TIME_0900, TIME_1700)); else if (a.getType().equals("leisure")) { a.setCapacity(this.nof_persons/leis_cnt); a.addOpeningTime(new OpeningTimeImpl(TIME_1700, TIME_2400));