MATSIM
CountSimComparisonImpl.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.*
3  * CountSimComparisonImpl.java
4  * *
5  * *********************************************************************** *
6  * *
7  * copyright : (C) 2007 by the members listed in the COPYING, *
8  * LICENSE and WARRANTY file. *
9  * email : info at matsim dot org *
10  * *
11  * *********************************************************************** *
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * See also COPYING, LICENSE and WARRANTY file *
18  * *
19  * *********************************************************************** */
20 
21 package org.matsim.counts;
22 
23 import org.matsim.api.core.v01.Id;
25 
31 public class CountSimComparisonImpl implements CountSimComparison {
35  private final int hour;
39  private final double countValue, simulationValue;
43  private final Id<Link> id;
47  private final String csId;
48 
55  @Deprecated
56  public CountSimComparisonImpl(final Id<Link> id, final int hour, final double countValue, final double simValue) {
57  this.id = id;
58  this.csId = null;
59  this.hour = hour;
60  this.countValue = countValue;
61  this.simulationValue = simValue;
62  }
63 
71  public CountSimComparisonImpl(final Id<Link> id, final String csId, final int hour, final double countValue, final double simValue) {
72  this.id = id;
73  this.csId = csId;
74  this.hour = hour;
75  this.countValue = countValue;
76  this.simulationValue = simValue;
77  }
78 
79  @Override
80  public String getCsId() {
81  return this.csId;
82  }
83 
88  @Override
89  public double calculateRelativeError() {
90  double count = this.getCountValue();
91  double sim = this.getSimulationValue();
92  if (count > 0) {
93  return Math.min((sim - count) / count, 1000d);
94  }
95  if (sim > 0) {
96  return 1000d;
97  }
98  return 0;
99  }
100 
104  @Override
105  public double getCountValue() {
106  return this.countValue;
107  }
108 
112  @Override
113  public int getHour() {
114  return this.hour;
115  }
116 
120  @Override
121  public Id<Link> getId() {
122  return this.id;
123  }
124 
128  @Override
129  public double getSimulationValue() {
130  return this.simulationValue;
131  }
132 
137  @Override
139  final double max = Math.max(this.simulationValue, this.countValue);
140  if (max == 0.0) return 0;
141  return Math.abs(this.simulationValue - this.countValue) / max;
142  }
143 
147  @Override
148  public double calculateGEHValue() {
149  final double diff = this.simulationValue - this.countValue;
150  final double sum = this.simulationValue + this.countValue;
151  final double gehV = Math.sqrt(2 * diff * diff / sum);
152  return gehV;
153  }
154 }
CountSimComparisonImpl(final Id< Link > id, final String csId, final int hour, final double countValue, final double simValue)
CountSimComparisonImpl(final Id< Link > id, final int hour, final double countValue, final double simValue)