MATSIM
Public Member Functions | Static Public Attributes | Private Attributes | List of all members
org.matsim.counts.Measurable Class Reference
Inheritance diagram for org.matsim.counts.Measurable:
Inheritance graph
[legend]

Public Member Functions

void setAtHour (int hour, double value)
 
void setAtMinute (int minute, double value)
 
void setAtSecond (int seconds, double value)
 
OptionalDouble getDailyValue ()
 
void setDailyValue (double value)
 
double aggregateDaily ()
 
OptionalDouble getAtHour (int hour)
 
boolean supportsHourlyAggregate ()
 
OptionalDouble aggregateAtHour (int hour)
 
OptionalDouble getAtSecond (int second)
 
OptionalDouble getAtMinute (int minutes)
 
String getMode ()
 
String getMeasurableType ()
 
int getInterval ()
 
Iterator< Int2DoubleMap.Entry > iterator ()
 
int size ()
 
boolean equals (Object o)
 
int hashCode ()
 

Static Public Attributes

static final String ANY_MODE = "any_vehicle"
 
static String VOLUMES = "volumes"
 
static String VELOCITIES = "velocities"
 
static String PASSENGERS = "passengers"
 
static int DAILY = 24 * 60 * 60
 
static int HOURLY = 60 * 60
 
static int QUARTER_HOURLY = 15 * 60
 

Private Attributes

final String type
 
final String mode
 
final Int2DoubleSortedMap values
 
final int interval
 

Detailed Description

A MeasurementLocation station can hold any kind of measurable data to calibrate a scenario provided as an implementation of this interface. A single instance holds values for only one transport mode. Average velocities and traffic volumes are already implemented.

Definition at line 16 of file Measurable.java.

Member Function Documentation

◆ setAtHour()

void org.matsim.counts.Measurable.setAtHour ( int  hour,
double  value 
)

Adds a value observed at a certain hour.

Definition at line 64 of file Measurable.java.

References org.matsim.counts.Measurable.setAtSecond().

Referenced by org.matsim.counts.Measurable.setDailyValue().

64  {
65  setAtSecond(hour * HOURLY, value);
66  }
void setAtSecond(int seconds, double value)
Definition: Measurable.java:76
Here is the call graph for this function:

◆ setAtMinute()

void org.matsim.counts.Measurable.setAtMinute ( int  minute,
double  value 
)

Adds a value observed at a certain minute. Note that the minute must match the given interval, for example if the intervall is set to 15 minutes the minute must be something like 15, 30, 45, 300 etc.

Definition at line 72 of file Measurable.java.

References org.matsim.counts.Measurable.setAtSecond().

72  {
73  setAtSecond(minute * 60, value);
74  }
void setAtSecond(int seconds, double value)
Definition: Measurable.java:76
Here is the call graph for this function:

◆ setAtSecond()

void org.matsim.counts.Measurable.setAtSecond ( int  seconds,
double  value 
)

Definition at line 76 of file Measurable.java.

Referenced by org.matsim.counts.CountsReaderMatsimV2.addValuesToMeasurable(), org.matsim.counts.Measurable.setAtHour(), and org.matsim.counts.Measurable.setAtMinute().

76  {
77  if (seconds < 0)
78  throw new IllegalArgumentException("Time value starts at 0.");
79 
80  if (seconds % this.interval != 0)
81  throw new IllegalArgumentException("Time value doesn't match the interval!");
82 
83  this.values.put(seconds, value);
84  }
final Int2DoubleSortedMap values
Definition: Measurable.java:43

◆ getDailyValue()

OptionalDouble org.matsim.counts.Measurable.getDailyValue ( )

Returns the observed daily value.

Definition at line 89 of file Measurable.java.

References org.matsim.counts.Measurable.getAtHour().

89  {
90  if (interval != DAILY)
91  throw new IllegalArgumentException("Does not contain daily values!");
92 
93  return getAtHour(0);
94  }
OptionalDouble getAtHour(int hour)
Here is the call graph for this function:

◆ setDailyValue()

void org.matsim.counts.Measurable.setDailyValue ( double  value)

Definition at line 96 of file Measurable.java.

References org.matsim.counts.Measurable.setAtHour().

96  {
97  if (interval != DAILY)
98  throw new IllegalArgumentException("Does not contain daily values!");
99 
100  setAtHour(0, value);
101  }
void setAtHour(int hour, double value)
Definition: Measurable.java:64
Here is the call graph for this function:

◆ aggregateDaily()

double org.matsim.counts.Measurable.aggregateDaily ( )

Return sum of values or daily value.

Definition at line 106 of file Measurable.java.

106  {
107  if (interval == DAILY)
108  return values.get(0);
109 
110  return values.values().doubleStream().sum();
111  }
final Int2DoubleSortedMap values
Definition: Measurable.java:43

◆ getAtHour()

OptionalDouble org.matsim.counts.Measurable.getAtHour ( int  hour)

Returns the observed value at a certain hour.

Definition at line 116 of file Measurable.java.

References org.matsim.counts.Measurable.getAtSecond().

Referenced by org.matsim.counts.Measurable.aggregateAtHour(), and org.matsim.counts.Measurable.getDailyValue().

116  {
117  return getAtSecond(hour * HOURLY);
118  }
OptionalDouble getAtSecond(int second)
Here is the call graph for this function:

◆ supportsHourlyAggregate()

boolean org.matsim.counts.Measurable.supportsHourlyAggregate ( )

Whether the interval allows for an hourly aggregation.

Definition at line 123 of file Measurable.java.

References org.matsim.counts.Measurable.interval.

Referenced by org.matsim.counts.Measurable.aggregateAtHour(), org.matsim.counts.Count< T >.Count(), and org.matsim.counts.Count< T >.getVolume().

123  {
124  return (interval <= HOURLY) && (HOURLY % interval) == 0;
125  }

◆ aggregateAtHour()

OptionalDouble org.matsim.counts.Measurable.aggregateAtHour ( int  hour)

Returns the aggregate for an specific hour. If the resolution does not allow this aggregation an error is thrpwn.

Definition at line 130 of file Measurable.java.

References org.matsim.counts.Measurable.getAtHour(), and org.matsim.counts.Measurable.supportsHourlyAggregate().

Referenced by org.matsim.counts.Count< T >.getVolume().

130  {
132  throw new IllegalArgumentException("Can not aggregate hourly values.");
133 
134  if (interval == HOURLY)
135  return getAtHour(hour);
136 
137  Int2DoubleSortedMap values = this.values.subMap(hour * HOURLY, (hour + 1) * HOURLY);
138  if (values.isEmpty())
139  return OptionalDouble.empty();
140 
141  return OptionalDouble.of(values.values().doubleStream().sum());
142  }
final Int2DoubleSortedMap values
Definition: Measurable.java:43
OptionalDouble getAtHour(int hour)
Here is the call graph for this function:

◆ getAtSecond()

OptionalDouble org.matsim.counts.Measurable.getAtSecond ( int  second)

Definition at line 144 of file Measurable.java.

Referenced by org.matsim.counts.Measurable.getAtHour(), and org.matsim.counts.Measurable.getAtMinute().

144  {
145  if (values.containsKey(second))
146  return OptionalDouble.of(values.get(second));
147 
148  return OptionalDouble.empty();
149  }
final Int2DoubleSortedMap values
Definition: Measurable.java:43

◆ getAtMinute()

OptionalDouble org.matsim.counts.Measurable.getAtMinute ( int  minutes)

Returns the observed value at a certain minute.

Definition at line 154 of file Measurable.java.

References org.matsim.counts.Measurable.getAtSecond().

154  {
155  return getAtSecond(minutes * 60);
156  }
OptionalDouble getAtSecond(int second)
Here is the call graph for this function:

◆ getMode()

String org.matsim.counts.Measurable.getMode ( )

Returns the transport mode of the observed data.

Definition at line 161 of file Measurable.java.

References org.matsim.counts.Measurable.mode.

161  {
162  return mode;
163  }

◆ getMeasurableType()

String org.matsim.counts.Measurable.getMeasurableType ( )

Returns the name of the implementation. Information is needed for data writing.

Definition at line 168 of file Measurable.java.

References org.matsim.counts.Measurable.type.

168  {
169  return type;
170  }

◆ getInterval()

int org.matsim.counts.Measurable.getInterval ( )

Definition at line 172 of file Measurable.java.

References org.matsim.counts.Measurable.interval.

Referenced by org.matsim.counts.Count< T >.Count().

172  {
173  return interval;
174  }

◆ iterator()

Iterator<Int2DoubleMap.Entry> org.matsim.counts.Measurable.iterator ( )

Iterate over all values as seconds-value pairs.

Definition at line 180 of file Measurable.java.

180  {
181  return values.int2DoubleEntrySet().iterator();
182  }
final Int2DoubleSortedMap values
Definition: Measurable.java:43

◆ size()

int org.matsim.counts.Measurable.size ( )

Number of entries.

Definition at line 187 of file Measurable.java.

Referenced by org.matsim.counts.Count< T >.toString().

187  {
188  return values.size();
189  }
final Int2DoubleSortedMap values
Definition: Measurable.java:43

◆ equals()

boolean org.matsim.counts.Measurable.equals ( Object  o)

Definition at line 192 of file Measurable.java.

References org.matsim.counts.Measurable.interval, org.matsim.counts.Measurable.mode, org.matsim.counts.Measurable.type, and org.matsim.counts.Measurable.values.

192  {
193  if (this == o) return true;
194  if (o == null || getClass() != o.getClass()) return false;
195  Measurable entries = (Measurable) o;
196  return interval == entries.interval && Objects.equals(type, entries.type) && Objects.equals(mode, entries.mode) && Objects.equals(values, entries.values);
197  }
final Int2DoubleSortedMap values
Definition: Measurable.java:43

◆ hashCode()

int org.matsim.counts.Measurable.hashCode ( )

Definition at line 200 of file Measurable.java.

200  {
201  return Objects.hash(type, mode, values, interval);
202  }
final Int2DoubleSortedMap values
Definition: Measurable.java:43

Member Data Documentation

◆ ANY_MODE

final String org.matsim.counts.Measurable.ANY_MODE = "any_vehicle"
static

String to denote that the mode includes all vehicles.

Definition at line 21 of file Measurable.java.

Referenced by org.matsim.counts.Count< T >.Count().

◆ VOLUMES

String org.matsim.counts.Measurable.VOLUMES = "volumes"
static

◆ VELOCITIES

String org.matsim.counts.Measurable.VELOCITIES = "velocities"
static

◆ PASSENGERS

String org.matsim.counts.Measurable.PASSENGERS = "passengers"
static

◆ DAILY

int org.matsim.counts.Measurable.DAILY = 24 * 60 * 60
static

Daily interval in seconds.

Definition at line 30 of file Measurable.java.

◆ HOURLY

int org.matsim.counts.Measurable.HOURLY = 60 * 60
static

◆ QUARTER_HOURLY

int org.matsim.counts.Measurable.QUARTER_HOURLY = 15 * 60
static

Quarter hourly interval in seconds.

Definition at line 38 of file Measurable.java.

◆ type

final String org.matsim.counts.Measurable.type
private

◆ mode

final String org.matsim.counts.Measurable.mode
private

◆ values

final Int2DoubleSortedMap org.matsim.counts.Measurable.values
private

Definition at line 43 of file Measurable.java.

Referenced by org.matsim.counts.Measurable.equals().

◆ interval

final int org.matsim.counts.Measurable.interval
private

The documentation for this class was generated from the following file: