Beispiel #1
0
  private static NumericMatrix getMatrix(Collection<PlainPerson> persons, LegPredicate pred) {
    NumericMatrix m = new NumericMatrix();

    for (Person person : persons) {
      for (Episode episode : person.getEpisodes()) {
        for (int i = 0; i < episode.getLegs().size(); i++) {
          Segment leg = episode.getLegs().get(i);
          if (pred.test(leg)) {
            Segment prev = episode.getActivities().get(i);
            Segment next = episode.getActivities().get(i + 1);

            String origin = prev.getAttribute(SetZones.ZONE_KEY);
            String dest = next.getAttribute(SetZones.ZONE_KEY);

            if (origin != null && dest != null) {
              m.add(origin, dest, 1);

              String touched = leg.getAttribute(DBG_TOUCHED);
              int cnt = 0;
              if (touched != null) cnt = Integer.parseInt(touched);
              leg.setAttribute(DBG_TOUCHED, String.valueOf(cnt + 1));
            }
          }
        }
      }
    }

    return m;
  }
Beispiel #2
0
  /*
   * (non-Javadoc)
   *
   * @see
   * playground.johannes.synpop.processing.EpisodeTask#apply(playground.johannes
   * .gsv.synPop.PlainEpisode)
   */
  @Override
  public void apply(Episode plan) {
    boolean hasVacations = false;
    for (Attributable act : plan.getActivities()) {
      if ("vacations".equalsIgnoreCase(act.getAttribute(CommonKeys.ACTIVITY_TYPE))) {
        hasVacations = true;
        break;
      }
    }

    if (hasVacations) {
      boolean isLong = false;

      Attributable first = plan.getLegs().get(0);
      Attributable last = plan.getLegs().get(plan.getLegs().size() - 1);

      String startStr = first.getAttribute(CommonKeys.LEG_START_TIME);
      String endStr = last.getAttribute(CommonKeys.LEG_END_TIME);

      if (startStr != null && endStr != null) {
        DateTime start = SplitPlanTask.formatter.parseDateTime(startStr);
        DateTime end = SplitPlanTask.formatter.parseDateTime(endStr);

        if (end.getDayOfYear() - start.getDayOfYear() > 3) {
          isLong = true;
        }
      }

      for (Attributable act : plan.getActivities()) {
        if ("vacations".equalsIgnoreCase(act.getAttribute(CommonKeys.ACTIVITY_TYPE))) {
          if (isLong) {
            act.setAttribute(CommonKeys.ACTIVITY_TYPE, "vacations_long");
          } else {
            act.setAttribute(CommonKeys.ACTIVITY_TYPE, "vacations_short");
          }
        }
      }
    }
  }
Beispiel #3
0
 /* (non-Javadoc)
  * @see playground.johannes.synpop.processing.EpisodeTask#apply(playground.johannes.synpop.data.PlainEpisode)
  */
 @Override
 public void apply(Episode plan) {
   for (Attributable act : plan.getActivities()) {
     String type = act.getAttribute(CommonKeys.ACTIVITY_TYPE);
     if ("pickdrop".equalsIgnoreCase(type)) {
       act.setAttribute(CommonKeys.ACTIVITY_TYPE, ActivityTypes.MISC);
     } else if ("private".equalsIgnoreCase(type)) {
       act.setAttribute(CommonKeys.ACTIVITY_TYPE, ActivityTypes.MISC);
     } else if ("intown".equalsIgnoreCase(type)) {
       act.setAttribute(CommonKeys.ACTIVITY_TYPE, ActivityTypes.MISC);
     } else if ("outoftown".equalsIgnoreCase(type)) {
       act.setAttribute(CommonKeys.ACTIVITY_TYPE, ActivityTypes.MISC);
     } else if ("unknown".equalsIgnoreCase(type)) {
       act.setAttribute(CommonKeys.ACTIVITY_TYPE, ActivityTypes.MISC);
     }
   }
 }
Beispiel #4
0
  @Override
  public void apply(Episode plan) {
    for (Segment act : plan.getActivities()) {
      String id = act.getAttribute(CommonKeys.ACTIVITY_FACILITY);
      ActivityFacility facility =
          facilities.getFacilities().get(Id.create(id, ActivityFacility.class));

      Coordinate c = new Coordinate(facility.getCoord().getX(), facility.getCoord().getY());
      CRSUtils.transformCoordinate(c, transform);

      Zone zone = zones.get(c);

      if (zone != null) {
        act.setAttribute(ZONE_KEY, zone.getAttribute(idKey));
      } else {
        notfound++;
      }
    }
  }