コード例 #1
0
  private void analyzeIntern(
      Set<Trajectory> trajectories, String purpose, TObjectDoubleHashMap<Trajectory> distancesMap) {
    TDoubleArrayList arrivals = new TDoubleArrayList(trajectories.size());
    TDoubleArrayList distances = new TDoubleArrayList(trajectories.size());

    for (Trajectory t : trajectories) {
      for (int i = 0; i < t.getElements().size(); i += 2) {
        if (purpose == null || ((Activity) t.getElements().get(i)).getType().equals(purpose)) {
          double start = t.getTransitions().get(i);
          arrivals.add(start);
          distances.add(distancesMap.get(t));
        }
      }
    }

    TDoubleDoubleHashMap map =
        Correlations.mean(arrivals.toNativeArray(), distances.toNativeArray(), 3600);
    //		Discretizer d = FixedSampleSizeDiscretizer.create(arrivals.toNativeArray(), 100, 100);
    //		TDoubleDoubleHashMap map = Correlations.mean(arrivals.toNativeArray(),
    // distances.toNativeArray(), d);
    try {
      if (purpose == null)
        StatsWriter.writeHistogram(
            map, "arr", "dist", String.format("%1$s/dist_arr.txt", getOutputDirectory()));
      else
        StatsWriter.writeHistogram(
            map,
            "arr",
            "dist",
            String.format("%1$s/dist_arr.%2$s.txt", getOutputDirectory(), purpose));
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
コード例 #2
0
ファイル: LegEvaluator.java プロジェクト: krlmlr/matsim
  @Override
  public double evaluate(Trajectory trajectory) {
    double score = 0;
    for (int i = 1; i < trajectory.getElements().size(); i += 2) {
      double t = trajectory.getTransitions().get(i + 1) - trajectory.getTransitions().get(i);
      score += beta * t;
    }

    if (isLogging) stats.addValue(score);

    return score;
  }
コード例 #3
0
  @Override
  public void analyze(Set<Trajectory> trajectories, Map<String, DescriptiveStatistics> results) {
    TObjectDoubleHashMap<Trajectory> distances = tripDistanceMean.values(trajectories);

    Set<String> purposes = new HashSet<String>();
    for (Trajectory t : trajectories) {
      for (int i = 0; i < t.getElements().size(); i += 2) {
        purposes.add(((Activity) t.getElements().get(i)).getType());
      }
    }

    for (String purpose : purposes) {
      analyzeIntern(trajectories, purpose, distances);
    }
    analyzeIntern(trajectories, null, distances);
  }