Exemplo n.º 1
0
  private DynamicIntArray initHistogram(Set<? extends Attributable> elements, String key) {
    DynamicIntArray array = new DynamicIntArray(12, 0);

    for (Attributable element : elements) {
      String strVal = element.getAttribute(key);
      if (strVal != null) {
        double value = Double.parseDouble(strVal);
        int bucket = discretizer.index(value);
        array.set(bucket, array.get(bucket) + 1);
      }
    }

    return array;
  }
Exemplo n.º 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");
          }
        }
      }
    }
  }
Exemplo n.º 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);
     }
   }
 }