public class ODMatrix extends Object implements Serializable, Identifiable
Class
's that define the categorization.
Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
Constructor and Description |
---|
ODMatrix(String id,
List<? extends Node> origins,
List<? extends Node> destinations,
Categorization categorization,
TimeVector globalTimeVector,
Interpolation globalInterpolation)
Constructs an OD matrix.
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(Node origin,
Node destination,
Category category) |
int |
destinationTotal(Node destination)
Calculates total number of trips over time for given destination.
|
boolean |
equals(Object obj) |
Set<Category> |
getCategories(Node origin,
Node destination)
Returns the categories specified for given origin-destination combination.
|
Categorization |
getCategorization() |
Frequency |
getDemand(Node origin,
Node destination,
Category category,
Time time,
boolean sliceStart)
Returns the demand at given time.
|
DemandPattern |
getDemandPattern(Node origin,
Node destination,
Category category) |
FrequencyVector |
getDemandVector(Node origin,
Node destination,
Category category) |
List<Node> |
getDestinations() |
Interpolation |
getGlobalInterpolation() |
TimeVector |
getGlobalTimeVector() |
String |
getId() |
Interpolation |
getInterpolation(Node origin,
Node destination,
Category category) |
List<Node> |
getOrigins() |
TimeVector |
getTimeVector(Node origin,
Node destination,
Category category) |
int |
getTrips(Node origin,
Node destination,
Category category,
int periodIndex)
Returns the number of trips in the given time period.
|
int[] |
getTripsVector(Node origin,
Node destination,
Category category) |
int |
hashCode() |
void |
increaseTrips(Node origin,
Node destination,
Category category,
int periodIndex,
int trips)
Adds a number of trips to given origin-destination combination, category and time period.
|
int |
matrixTotal()
Calculates total number of trips over time for the complete matrix.
|
int |
originDestinationTotal(Node origin,
Node destination)
Calculates total number of trips over time for given origin-destination combination.
|
int |
originTotal(Node origin)
Calculates total number of trips over time for given origin.
|
void |
print()
Prints the complete OD matrix with each demand data on a single line.
|
void |
putDemandVector(Node origin,
Node destination,
Category category,
FrequencyVector demand)
Add a demand vector to OD.
|
void |
putDemandVector(Node origin,
Node destination,
Category category,
FrequencyVector demand,
TimeVector timeVector,
Interpolation interpolation)
Add a demand vector to OD.
|
void |
putDemandVector(Node origin,
Node destination,
Category category,
FrequencyVector demand,
TimeVector timeVector,
Interpolation interpolation,
double fraction)
Add a demand vector to OD, by a fraction of total demand.
|
void |
putDemandVector(Node origin,
Node destination,
Category category,
FrequencyVector demand,
TimeVector timeVector,
Interpolation interpolation,
double[] fraction)
Add a demand vector to OD, by a fraction per time period of total demand.
|
void |
putTripsVector(Node origin,
Node destination,
Category category,
int[] trips) |
void |
putTripsVector(Node origin,
Node destination,
Category category,
int[] trips,
TimeVector timeVector)
Sets demand data by number of trips.
|
String |
toString() |
public ODMatrix(String id, List<? extends Node> origins, List<? extends Node> destinations, Categorization categorization, TimeVector globalTimeVector, Interpolation globalInterpolation)
id
- String; idorigins
- List<? extends Node>; origin nodesdestinations
- List<? extends Node>; destination nodescategorization
- Categorization; categorization of dataglobalTimeVector
- TimeVector; default timeglobalInterpolation
- Interpolation; interpolation of demand dataNullPointerException
- if any input is nullpublic final String getId()
getId
in interface Identifiable
public final Categorization getCategorization()
public final TimeVector getGlobalTimeVector()
public final Interpolation getGlobalInterpolation()
public final void putDemandVector(Node origin, Node destination, Category category, FrequencyVector demand)
origin
- Node; origindestination
- Node; destinationcategory
- Category; categorydemand
- FrequencyVector; demand data, length has to be equal to the global time vectorIllegalArgumentException
- if origin or destination is not part of the OD matrixIllegalArgumentException
- if the category does not belong to the categorizationIllegalArgumentException
- if the demand data has a different length than time data, or is less than 2IllegalArgumentException
- if demand is negative or time not strictly increasingIllegalArgumentException
- if the route (if in the category) is not from the origin to the destinationNullPointerException
- if an input is nullpublic final void putDemandVector(Node origin, Node destination, Category category, FrequencyVector demand, TimeVector timeVector, Interpolation interpolation)
origin
- Node; origindestination
- Node; destinationcategory
- Category; categorydemand
- FrequencyVector; demand data, length has to be equal to the time vectortimeVector
- TimeVector; time vectorinterpolation
- Interpolation; interpolationIllegalArgumentException
- if origin or destination is not part of the OD matrixIllegalArgumentException
- if the category does not belong to the categorizationIllegalArgumentException
- if the demand data has a different length than time data, or is less than 2IllegalArgumentException
- if demand is negative or time not strictly increasingIllegalArgumentException
- if the route (if in the category) is not from the origin to the destinationNullPointerException
- if an input is nullpublic final void putDemandVector(Node origin, Node destination, Category category, FrequencyVector demand, TimeVector timeVector, Interpolation interpolation, double fraction)
origin
- Node; origindestination
- Node; destinationcategory
- Category; categorydemand
- FrequencyVector; demand data, length has to be equal to the time vectortimeVector
- TimeVector; time vectorinterpolation
- Interpolation; interpolationfraction
- double; fraction of demand for this categoryIllegalArgumentException
- if origin or destination is not part of the OD matrixIllegalArgumentException
- if the category does not belong to the categorizationIllegalArgumentException
- if the demand data has a different length than time data, or is less than 2IllegalArgumentException
- if demand is negative or time not strictly increasingIllegalArgumentException
- if the route (if in the category) is not from the origin to the destinationNullPointerException
- if an input is nullpublic final void putDemandVector(Node origin, Node destination, Category category, FrequencyVector demand, TimeVector timeVector, Interpolation interpolation, double[] fraction)
origin
- Node; origindestination
- Node; destinationcategory
- Category; categorydemand
- FrequencyVector; demand data, length has to be equal to the time vectortimeVector
- TimeVector; time vectorinterpolation
- Interpolation; interpolationfraction
- double[]; fraction of demand for this categoryIllegalArgumentException
- if origin or destination is not part of the OD matrixIllegalArgumentException
- if the category does not belong to the categorizationIllegalArgumentException
- if the demand data has a different length than time data, or is less than 2IllegalArgumentException
- if demand is negative or time not strictly increasingIllegalArgumentException
- if the route (if in the category) is not from the origin to the destinationNullPointerException
- if an input is nullpublic final FrequencyVector getDemandVector(Node origin, Node destination, Category category)
origin
- Node; origindestination
- Node; destinationcategory
- Category; categorynull
if no data is givenIllegalArgumentException
- if origin or destination is not part of the OD matrixIllegalArgumentException
- if the category does not belong to the categorizationNullPointerException
- if an input is nullpublic final TimeVector getTimeVector(Node origin, Node destination, Category category)
origin
- Node; origindestination
- Node; destinationcategory
- Category; categorynull
if no data is givenIllegalArgumentException
- if origin or destination is not part of the OD matrixIllegalArgumentException
- if the category does not belong to the categorizationNullPointerException
- if an input is nullpublic final Interpolation getInterpolation(Node origin, Node destination, Category category)
origin
- Node; origindestination
- Node; destinationcategory
- Category; categorynull
if no data is givenIllegalArgumentException
- if origin or destination is not part of the OD matrixIllegalArgumentException
- if the category does not belong to the categorizationNullPointerException
- if an input is nullpublic final Frequency getDemand(Node origin, Node destination, Category category, Time time, boolean sliceStart)
origin
- Node; origindestination
- Node; destinationcategory
- Category; categorytime
- Time; timesliceStart
- boolean; whether the time is at the start of an arbitrary time sliceIllegalArgumentException
- if origin or destination is not part of the OD matrixIllegalArgumentException
- if the category does not belong to the categorizationNullPointerException
- if an input is nullpublic DemandPattern getDemandPattern(Node origin, Node destination, Category category)
origin
- Node; origindestination
- Node; destinationcategory
- Category; categoryIllegalArgumentException
- if origin or destination is not part of the OD matrixIllegalArgumentException
- if the category does not belong to the categorizationNullPointerException
- if an input is nullpublic final boolean contains(Node origin, Node destination, Category category)
origin
- Node; origindestination
- Node; destinationcategory
- Category; categoryIllegalArgumentException
- if origin or destination is not part of the OD matrixIllegalArgumentException
- if the category does not belong to the categorizationNullPointerException
- if an input is nullpublic final Set<Category> getCategories(Node origin, Node destination)
origin
- Node; origindestination
- Node; destinationIllegalArgumentException
- if origin or destination is not part of the OD matrixNullPointerException
- if an input is nullpublic final void putTripsVector(Node origin, Node destination, Category category, int[] trips)
origin
- Node; origindestination
- Node; destinationcategory
- Category; categorytrips
- int[]; trip data, length has to be equal to the global time vector - 1, each value is the number of trips
during a periodIllegalArgumentException
- if origin or destination is not part of the OD matrixIllegalArgumentException
- if the category does not belong to the categorizationIllegalArgumentException
- if the demand data has a different length than time data, or is less than 2IllegalArgumentException
- if demand is negative or time not strictly increasingIllegalArgumentException
- if the route (if in the category) is not from the origin to the destinationNullPointerException
- if an input is nullpublic final void putTripsVector(Node origin, Node destination, Category category, int[] trips, TimeVector timeVector)
origin
- Node; origindestination
- Node; destinationcategory
- Category; categorytrips
- int[]; trip data, length has to be equal to the time vector - 1, each value is the number of trips during a
periodtimeVector
- TimeVector; time vectorIllegalArgumentException
- if origin or destination is not part of the OD matrixIllegalArgumentException
- if the category does not belong to the categorizationIllegalArgumentException
- if the demand data has a different length than time data, or is less than 2IllegalArgumentException
- if demand is negative or time not strictly increasingIllegalArgumentException
- if the route (if in the category) is not from the origin to the destinationNullPointerException
- if an input is nullpublic final int[] getTripsVector(Node origin, Node destination, Category category)
origin
- Node; origindestination
- Node; destinationcategory
- Category; categorynull
if no data is givenIllegalArgumentException
- if origin or destination is not part of the OD matrixIllegalArgumentException
- if the category does not belong to the categorizationNullPointerException
- if an input is nullpublic final int getTrips(Node origin, Node destination, Category category, int periodIndex)
origin
- Node; origindestination
- Node; destinationcategory
- Category; categoryperiodIndex
- int; index of time periodIllegalArgumentException
- if origin or destination is not part of the OD matrixIllegalArgumentException
- if the category does not belong to the categorizationIndexOutOfBoundsException
- if the period is outside of the specified rangeNullPointerException
- if an input is nullpublic final void increaseTrips(Node origin, Node destination, Category category, int periodIndex, int trips)
origin
- Node; origindestination
- Node; destinationcategory
- Category; categoryperiodIndex
- int; index of time periodtrips
- int; trips to add (may be negative)IllegalArgumentException
- if origin or destination is not part of the OD matrixIllegalArgumentException
- if the category does not belong to the categorizationIndexOutOfBoundsException
- if the period is outside of the specified rangeUnsupportedOperationException
- if the interpolation of the data is not stepwise, or demand becomes negtiveNullPointerException
- if an input is nullpublic final int originTotal(Node origin)
origin
- Node; originIllegalArgumentException
- if origin is not part of the OD matrixNullPointerException
- if origin is nullpublic final int destinationTotal(Node destination)
destination
- Node; destinationIllegalArgumentException
- if destination is not part of the OD matrixNullPointerException
- if destination is nullpublic final int matrixTotal()
IllegalArgumentException
- if origin or destination is not part of the OD matrixNullPointerException
- if an input is nullpublic final int originDestinationTotal(Node origin, Node destination)
origin
- Node; origindestination
- Node; destinationIllegalArgumentException
- if origin or destination is not part of the OD matrixNullPointerException
- if an input is nullpublic final void print()
Copyright © 2014–2019 Delft University of Technology. All rights reserved.