public final ActivityFacilityImpl createAndAddFacility(final Id<ActivityFacility> id, final Coord center, final Id<Link> linkId) { if (this.facilities.containsKey(id)) { throw new IllegalArgumentException("Facility with id=" + id + " already exists."); } ActivityFacilityImpl f = new ActivityFacilityImpl(id, center, linkId); this.facilities.put(f.getId(),f); // show counter if (this.facilities.size() % this.nextMsg == 0) { this.nextMsg *= 2; log.info(" facility # " + this.facilities.size() ); } return f; }
public void startFacility(final ActivityFacilityImpl facility, final BufferedWriter out) throws IOException { out.write("\t<facility"); out.write(" id=\"" + facility.getId() + "\""); if (facility.getLinkId() != null) { out.write(" linkId=\"" + facility.getLinkId().toString() + "\""); } if (facility.getCoord()!=null) { final Coord coord = coordinateTransformation.transform(facility.getCoord()); out.write(" x=\"" + coord.getX() + "\""); out.write(" y=\"" + coord.getY() + "\""); } if (facility.getDesc() != null) { out.write(" desc=\"" + facility.getDesc() + "\""); } 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."); } }
private void setNewLocationForAct(Activity act, int length) { ActivityFacilityImpl facility = this.facilitiesOfType.get(act.getType())[super.random.nextInt(length)]; act.setFacilityId(facility.getId()); act.setLinkId(NetworkUtils.getNearestLink(((Network) this.scenario.getNetwork()), facility.getCoord()).getId()); act.setCoord(facility.getCoord()); } }